Profiel van Jun睦和庭Foto'sWeblogLijstenMeer Extra Help

Weblog


    25 oktober

    试刊?

    接触了些些电子书具体制作。
    的确,BLOG没有电子书香艳。
    电子书才有更多的空间。
     
     
    拟作了封面。希望大家能有素材提供。
     
     
     
     
    21 oktober

    Problem D: Hansel and Gretel

     

    Hummm~~ Now I got time to sit down and type sth.

    Yup, last weekend, I went to the programming competition again which holded at Cape Breton University near by Sydney, NS 

    The thing is that I do still feel guiltily this time. Last year, I felt guiltily coz that I just could sit down and doing nothing important. Now, this time, I felt so sorry. If I could explain the algorithms well, or we did not misunderstand of input method, we may go to the next level of the programming competition. However, my landlord, when I was in Halifax, said is right "No excuse, only loser needs explanation".

    Anyway, it was a great experience even we did not win. Each time I hang out with Canadians, I did know lots new stuff. I do appreciate you guys. Thanks~

    Here is the most guiltily problem which I did not make clear.

    ==================================================================================

    Problem D: Hansel and Gretel

    Hansel and Gretel are wandering in the woods when an evil witch gives them a bucket of chocolate. In the bucket there are a variable number of chocolate bars, from 0 to 1000. The bars can weigh any amount, from 1 to 1000 grams, but will always be an exact integer value. That is bars can weigh 1 gram, 2 grams, 3 grams, and so on, and will never have a fractional weight such as 1.5 grams or 3.75 grams. The witch is evil because it is very hard for Hansel and Gretel to divide the chocolate fairly, causing them to get into very bad arguments. Your task is to help prevent Hansel and Gretel from fighting by dividing the chocolate for them.

    Input

    The first line of input will contain a single integer, b, indicating the number of buckers of chocolate you will have to divide. After this, there are b sets of data, one for each bucker. Each set of data begins with a single integer, n, indicating the number of chocolate bars in the bucket. Then, the next n lines will each contain a single integer indicating the weight of a bar of chocolate.

    Output

    You are tow output two integers, on the same line, with a single space between them. The first integer is the amount of chocolate that Gretel gets and the second integer is the amount of chocolate that Hansel gets. You must ensure that the difference between Hansel’s and Gretel’s amounts in minimal for each bucker. If the bucket can not be divided into two even sized piles, Gretel will get the larger pile.

    Example Input                                               Example Output

    2                                                                                              7  7
    4                                                                                              2  1
    2
    3
    4
    5
    3
    1
    1
    1

    ==================================================================================

    Well~~~ Actually, this problem is quite easy.

    First read in the a single integer for the counter of total dividing times.

    Then get the counter for the number of chocolate bars in the bucket. It is used for identifying the end of each dividing.

    Then, it comes the most trick part of this problem. Since from the question, we know that we just have integer and we can not cut the bar into two pieces. So, what I thought was about comparing the difference of each possible combination of the half number of the bars. If there is a combination which the difference is zero, then the bucket of chocolate can be divided equally. If not, we get the combination with smallest difference and do as the question said, let Gretel get the larger pile.

    Now, the problem is how can we do the "comparing the difference of each possible combination of the half number of the bars". One method I had at that time was doing by two arrays. Put first half into an array(array_1) and the rest into another array(array_2). Removing the first element in array and adding each element in array_2. Comparing the difference each time and store the smallest difference and the combination. And restore the removed element and remove the next one.

    It looks like almost solved, but we still have a tiny problem. If the number of chocolate is odd, how to set the two arrays. Well, it is easy, just add one element with zero value into the end array_2, and do the same thing as even number of chocolate.

    At this point, we can say the problem is solved. What left is just some coding part.

     

    Some pics took during this event:

    At daytime, the MacBook is onwed by her really onwer.

     

    But when the dark comes, MacBook becomes my biotch.

     

    Waiting for the programming competition.  

     

    The Banquet  

    09 oktober

    梦里花落知多少

     
     
     
     
    回到森庄的窝快一个月了,真是亲切。多久没有在午夜前不入睡,早晨在鸟鸣中醒来了?好象是很久很久以前了。一切都有了点陌生,好象漫长的小学时的暑假,虽然那时还没有电脑和网络。
     
    附近的地方,或者各种寓所的附近、各样的街头、田野和山间......有时很静,只有风和植物的声音。漫步在野生植物弥漫的地方,人迹稀少,感觉很是玄妙,象做梦一样。
     
    最近天色都迷蒙的紧,一看日历,才想起立秋很久了。
     
    我唯一恐惧的就是无所事事,毕竟生命只有一回。我还要好好想想,丰富多采的历程才是最诱人的。我不想放弃什么,却更不想失去享受。
     
     
     
     
     

    酱红脸膛:
    什么是自己看的见,又摸的着的呢?那我早就去摸了,除非太费劲,否则被打一下也是一种体验吗?
    “每个人都有属于自己的路,你在羡慕别人的时候,也许更多的人却在羡慕着你。”
     
    白云:
    男孩做想做的事,成熟男人做该做的事。

    酱红脸膛:
    也对,但成熟是追求的标准吗,恐怕,童心未泯更是对吧?
    起码,不会后悔,遗憾和错过。

    白云:
    是啊,生活方式和生活理念决定了生活的态度。
    你思考的方式挺好的,保持啊。

    酱红脸膛:
    我现在是没态度了,生活就像是午饭,好吃与否,目的只是维生。
    好在我们还有晚饭,但比吃更重要的是和谁一起,务必要有酒。
    爱情也许是一个人生命中最重要的一个追求,或者说是最重要追求的附加值,反正对我是这样的。
    也许有一天,突然发现,生活变得十分的开阔,甚至自由。
    虽然不会有一丝一毫的庆幸,而且再也没有可能产生幸福的感觉...
     
     
     
     
     
    感恩节,收拾了一天。炉子上煲着汤,电脑里放着《麦兜的故事》。平和、柔情似水,淡淡而悠长的哀伤。这正是生活的基调,正是动荡的感情给平淡的生活带来波动,影响我的心情。促使对于生命的思考:得之,我幸;不得,我命。如此而已,何必强求。
     

    收拾东西往往要花很久的时间,而把它们从箱子里那出来恐怕要很久呢,尤其是如此的复杂和凌乱。
    整理家中的旧物,仿佛考古一样......发现一首许久以前的小诗。到是和谐的很:
       “在书本里我发现了一朵小花
          早已干枯,心不在芬芳
          是哪一个春天,在哪处
          可是为了纪念温柔的会见
          还是留着  永久的别情
          或者只是由于孤独的散步
          在田野的幽寂处、在林荫
          是他还是她,还记得吗
          哪一个角落是它们的家  也许他们早已经枯萎了
          ——如这朵不知名的小花。”
     
     
    07 oktober

    照片

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    03 oktober

    生活如果是首慢歌,我就可以慢慢淌过你的河

     
     
     
     
        又重新听回了孙燕姿。
        这个皮肤不怎么样,瘦到几乎没有肉的女孩刚刚出专辑时,谁也没有想到她会红成这样。

        我还记得那年夏天放暑假,我在淘CD时,老板极力向我推荐的新人的CD。花了8块钱,一路套着耳机听回了家。
        她的声线多么独特,后来的绿光和神奇再红。
        还是怀念躲在被子里反复听“天黑黑”的日子。
        就像怀念那种在课堂上传小纸条感觉一样,那些青春岁月缓缓的,缓缓地不见了。剩下了快歌满天飞的年代。

        慢歌的味道是渐渐漫上来的,可惜这个世界总是太浮躁。
     
     
     
     
     
     
     
    ------------------------------------------------
    我活着埋葬我的欲望,将我的心,烧成灰末。
     
     
     
     
    *