<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2732629504988178457</id><updated>2012-02-17T11:20:27.841+08:00</updated><category term='Python'/><category term='燈'/><category term='流到香江'/><category term='ACM'/><category term='css'/><category term='JAVA'/><category term='Ruby'/><category term='路上的風景'/><category term='趨光'/><category term='Rails'/><category term='Christmas'/><category term='Real Estate'/><category term='Projects'/><category term='HTML'/><category term='黑夜'/><category term='Notepad'/><category term='Google App Engine'/><category term='Lists'/><title type='text'>The Tagtraum House</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default?start-index=101&amp;max-results=100'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>205</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1719686937463049268</id><published>2011-12-15T15:13:00.001+08:00</published><updated>2011-12-15T15:13:47.044+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><category scheme='http://www.blogger.com/atom/ns#' term='Christmas'/><title type='text'>Have Yourself A Merry Little Christmas</title><content type='html'>&lt;p&gt;One of my favorite Christmas song. Accuradio has a channel &lt;a href="http://www.accuradio.com/player/slipstream/accuholidays/365/"&gt;“Have Yourself A Merry Little Christmas”&lt;/a&gt; that plays various versions of this song. That is so nice. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Have Yourself A Merry Little Christmas – Lyrics&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Music composed by Hugh Martin, lyrics by Ralph Blane&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Have yourself a merry little Christmas,   &lt;br /&gt;Let your heart be light    &lt;br /&gt;From now on,    &lt;br /&gt;our troubles will be out of sight&lt;/p&gt;  &lt;p&gt;Have yourself a merry little Christmas,   &lt;br /&gt;Make the Yule-tide gay,    &lt;br /&gt;From now on,     &lt;br /&gt;our troubles will be miles away.&lt;/p&gt;  &lt;p&gt;Here we are as in olden days,   &lt;br /&gt;Happy golden days of yore.    &lt;br /&gt;Faithful friends who are dear to us    &lt;br /&gt;Gather near to us once more.&lt;/p&gt;  &lt;p&gt;Through the years    &lt;br /&gt;We all will be together,    &lt;br /&gt;If the Fates allow    &lt;br /&gt;Hang a shining star upon the highest bough.    &lt;br /&gt;And have yourself A merry little Christmas now.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1719686937463049268?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1719686937463049268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/12/have-yourself-merry-little-christmas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1719686937463049268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1719686937463049268'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/12/have-yourself-merry-little-christmas.html' title='Have Yourself A Merry Little Christmas'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5254507133706676677</id><published>2011-12-07T11:22:00.001+08:00</published><updated>2011-12-07T11:22:11.723+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>洪卓立 - 愛別等</title><content type='html'>&lt;p&gt;好聽好聽~~&lt;/p&gt;  &lt;p&gt;&lt;iframe height="315" src="http://www.youtube.com/embed/R-sDcD9XtgI" frameborder="0" width="420" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;/p&gt;  &lt;p&gt;作曲：Johnny Yim   &lt;br /&gt;填詞：陳姿喬@Zoo Music    &lt;br /&gt;編曲：Johnny Yim&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;無聊隨意獨行 從來無意搜尋   &lt;br /&gt;情感空洞内心怕自問 愛得深但剩得天真&lt;/p&gt;  &lt;p&gt;悠然和你共行 平凡輪廓怎相襯   &lt;br /&gt;偷望著加點留神 沿途漫步確認真摯聲音&lt;/p&gt;  &lt;p&gt;＊日落逐漸近 像蜜運在附近   &lt;br /&gt; 相戀不必一定地震天    &lt;br /&gt; 腳步開始走近 眉目再對望即將發生    &lt;br /&gt; 夜半一吻突然動心 抱緊早已認識的人    &lt;br /&gt; 難得跟情人思想同行 每段説話深得我心    &lt;br /&gt; 明日又能為誰認真 若這刻輕率轉身    &lt;br /&gt; 遺失這情人 怎可再等    &lt;br /&gt; 喜歡你聽懂我心 快著緊（愛別等）＊&lt;/p&gt;  &lt;p&gt;仍然隨意漫遊 閒談微笑交流   &lt;br /&gt;談占星命運心理學問 你的聲音另有質感&lt;/p&gt;  &lt;p&gt;Repeat （＊）&lt;/p&gt;  &lt;p&gt;世事總變化 難設想最差   &lt;br /&gt;同預測天氣越早休假    &lt;br /&gt;投入地種二人的花&lt;/p&gt;  &lt;p&gt;夜半一吻突然動心 帶走苦澀内心傷痕   &lt;br /&gt;能公開成爲知己情人 每日每夜傾身貼心&lt;/p&gt;  &lt;p&gt;明日又能為誰認真 若這刻輕率轉身   &lt;br /&gt;遺失這情人 怎可再等    &lt;br /&gt;喜歡你 聽懂我心愛別等    &lt;br /&gt;喜歡你 必須發生吻入心&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5254507133706676677?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5254507133706676677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/12/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5254507133706676677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5254507133706676677'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/12/blog-post.html' title='洪卓立 - 愛別等'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/R-sDcD9XtgI/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-2735106864523527969</id><published>2011-11-29T16:33:00.001+08:00</published><updated>2011-11-29T16:38:10.787+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google App Engine'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Python utf-8 decoding problem</title><content type='html'>今天用Python/Google App Engine寫網站時遇到的error message:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa4 in position 57: invalid start byte&lt;/pre&gt;
&lt;br /&gt;
中文無法正常顯示，後來查到的解決方式是：把檔案編碼方式改成utf-8即可正常顯示。&lt;br /&gt;
reference:&amp;nbsp;&lt;a href="http://bbs.chinaunix.net/archiver/tid-2332880.html"&gt;http://bbs.chinaunix.net/archiver/tid-2332880.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-2735106864523527969?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/2735106864523527969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/11/python-utf-8-decoding-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2735106864523527969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2735106864523527969'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/11/python-utf-8-decoding-problem.html' title='Python utf-8 decoding problem'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8510385285660907465</id><published>2011-06-19T00:31:00.001+08:00</published><updated>2011-06-19T00:40:27.922+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>Melody–Realize (龍櫻op)</title><content type='html'>&lt;iframe height="349" src="http://www.youtube.com/embed/6Anu9ztGfHY" frameborder="0" width="425" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;作詞：melody. /MIZUE   &lt;br /&gt;作曲：Koutaro Odaka    &lt;br /&gt;編曲：Kei &amp;quot;Spicy&amp;quot; Kawano&lt;/p&gt;  &lt;p&gt;(日文)&lt;/p&gt;  &lt;p&gt;I can 迷わずに 進もう    &lt;br /&gt;願いに 近ずけるよ     &lt;br /&gt;I see the light     &lt;br /&gt;Wake up, stand up     &lt;br /&gt;もう一度 明日へ try &lt;/p&gt;  &lt;p&gt;Look at my 小さいの手で    &lt;br /&gt;Hold on tight つかまえた my precious     &lt;br /&gt;なくしそうな visions is me     &lt;br /&gt;見失いたくない 自分のway &lt;/p&gt;  &lt;p&gt;Do you know that I want it all    &lt;br /&gt;心の奥で 輝き つずける     &lt;br /&gt;その夢を 忘れないで &lt;/p&gt;  &lt;p&gt;I can 迷わずに 進もう    &lt;br /&gt;願いに 近ずけるよ &lt;/p&gt;  &lt;p&gt;いつの日にか 溢れる 光の花を咲かせよう    &lt;br /&gt;I see the light     &lt;br /&gt;Wake up, stand up     &lt;br /&gt;もう一度 明日へ try &lt;/p&gt;  &lt;p&gt;Here I am 瞳閉じたら    &lt;br /&gt;独りじゃないことに 気ずいた     &lt;br /&gt;乾いていた 心が 嬉しい 涙に染まる Once again &lt;/p&gt;  &lt;p&gt;I promise 今から    &lt;br /&gt;この胸の中で 動き始めた     &lt;br /&gt;この鼓動 感じながら &lt;/p&gt;  &lt;p&gt;I will 思い切り つらぬく    &lt;br /&gt;このまま 走りたいから     &lt;br /&gt;いつの日にか 夢見た場所で     &lt;br /&gt;A-ha-ha と笑っているでしょ     &lt;br /&gt;Wake up, stand up     &lt;br /&gt;何度でも Get up and try&lt;/p&gt;  &lt;p&gt;Carry on…..    &lt;br /&gt;I realize     &lt;br /&gt;I realize     &lt;br /&gt;That we can get there &lt;/p&gt;  &lt;p&gt;I can 迷わずに 進もう    &lt;br /&gt;願いに 近ずけるよ &lt;/p&gt;  &lt;p&gt;いつの日にか 溢れる 光の花を咲かせよう&lt;/p&gt;  &lt;p&gt;I will 思い切り つらぬく    &lt;br /&gt;このまま 走りたいから     &lt;br /&gt;いつの日にか 夢見た場所で     &lt;br /&gt;A-ha-ha と笑っているでしょ     &lt;br /&gt;Wake up, stand up     &lt;br /&gt;何度でも Get up and try &lt;/p&gt;  &lt;p&gt;(中譯)&lt;/p&gt;  &lt;p&gt;對著不再迷惘的未來前進吧    &lt;br /&gt;向願望接近吧     &lt;br /&gt;I see the light     &lt;br /&gt;wake up, stand up     &lt;br /&gt;再一次 對著明天去嘗試 &lt;/p&gt;  &lt;p&gt;看我用小小的這雙手    &lt;br /&gt;緊緊抓住 獲得的珍貴東西     &lt;br /&gt;這種稍縱即逝的想法 卻是我     &lt;br /&gt;不想丟失的，自己的道路 &lt;/p&gt;  &lt;p&gt;Do you know that I want it all    &lt;br /&gt;在心的深處 持續閃耀的     &lt;br /&gt;這個夢想 是絕對不會忘記的&lt;/p&gt;  &lt;p&gt;對著不再迷惘的未來前進吧    &lt;br /&gt;向願望接近     &lt;br /&gt;也許某一天吧     &lt;br /&gt;滿溢著光輝的花朵就會綻放     &lt;br /&gt;I see the light     &lt;br /&gt;wake up, stand up     &lt;br /&gt;再一次 向明天 嘗試 &lt;/p&gt;  &lt;p&gt;Here I am 閉上雙眼的話    &lt;br /&gt;就會意識到 其實並不孤獨     &lt;br /&gt;乾涸的心     &lt;br /&gt;再一次被高興的淚水所溼潤 &lt;/p&gt;  &lt;p&gt;I promise 從今天開始    &lt;br /&gt;在胸中 開始澎湃的     &lt;br /&gt;這個鼓動 我感覺到了 &lt;/p&gt;  &lt;p&gt;★我會下定決心 貫徹到底    &lt;br /&gt;想要就這樣子一路奔跑下去     &lt;br /&gt;所以，也許某一天 能在夢中所盼望的地方     &lt;br /&gt;a-ha-ha 開懷地笑著吧     &lt;br /&gt;wake up, stand up     &lt;br /&gt;不管是幾次 get up and try ★ &lt;/p&gt;  &lt;p&gt;carry on...    &lt;br /&gt;I realize     &lt;br /&gt;I realize     &lt;br /&gt;that we can get there &lt;/p&gt;  &lt;p&gt;對著不再迷惘的未來前進吧    &lt;br /&gt;向願望接近吧 &lt;/p&gt;  &lt;p&gt;也許某一天    &lt;br /&gt;滿溢著光耀的花朵就會綻放&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8510385285660907465?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8510385285660907465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/06/melodyrealize-op.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8510385285660907465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8510385285660907465'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/06/melodyrealize-op.html' title='Melody–Realize (龍櫻op)'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/6Anu9ztGfHY/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5220834003962722820</id><published>2011-02-27T15:47:00.001+08:00</published><updated>2011-02-27T15:54:13.359+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>Plants vs Zombies soundtrack</title><content type='html'>&lt;p&gt;Plants vs Zombies is my favorite game recently. What fascinates me most is its graphic design and music. The music is from Laura Shigihara, from &lt;a href="http://en.wikipedia.org/wiki/Plants_vs._Zombies#Soundtrack" target="_blank"&gt;Wiki&lt;/a&gt; I learned that she wants to mix in melodic tunes and funky beats! One of my favorite song in this game is its main menu background music. It is:&lt;/p&gt; &lt;iframe title="YouTube video player" height="349" src="http://www.youtube.com/embed/Y-ctNIB3kEY" frameborder="0" width="425" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;I like it especially from 0:35!&lt;/p&gt;  &lt;p&gt;This is one is also good. 好鬼得意！&lt;/p&gt; &lt;iframe title="YouTube video player" height="349" src="http://www.youtube.com/embed/0N1_0SUGlDQ" frameborder="0" width="425" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5220834003962722820?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5220834003962722820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/plants-vs-zombies-soundtrack.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5220834003962722820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5220834003962722820'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/plants-vs-zombies-soundtrack.html' title='Plants vs Zombies soundtrack'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/Y-ctNIB3kEY/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-4037170251115250619</id><published>2011-02-10T21:17:00.000+08:00</published><updated>2011-02-10T22:28:27.712+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Scaling for IE/Chrome/Firefox/Safari</title><content type='html'>&lt;p&gt;I want a scaling that works for all above browsers. I end up with two separate style sheets, one for IE, and one for the rest browsers. And I did something like this:&lt;/p&gt;  &lt;div style="background: #ECECEC; font: bold 24px Arial;"&gt;This is sample text before scale&lt;/div&gt; &lt;div class="myclass"&gt;This is sample text after scale&lt;/div&gt; &lt;!-- general styles --&gt; &lt;style type="text/css"&gt;
.myclass {
    width: 100%;
    background: #ECECEC;
    font: bold 24px Arial;
}
&lt;/style&gt;  &lt;!-- IE styles --&gt; &lt;!--[if IE]&gt;
&lt;style type="text/css"&gt;
.myclass {
    zoom: 0.6;
}
&lt;/style&gt;
&lt;![endif]--&gt;  &lt;!-- mozilla firefox and webkit browsers(chrome/safari) styles --&gt; &lt;!--[if !IE]&gt;--&gt; &lt;style type="text/css"&gt;
.myclass {
    -moz-transform: scale(0.6);
    -webkit-transform: scale(0.6);
}
&lt;/style&gt; &lt;!--&lt;![endif]--&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;myclass&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;This is sample text&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
.myclass {
    width: 100%;
    background: #ECECEC;
    font: bold 24px Arial;
}
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="rem"&gt;&amp;lt;!--[if IE]&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;.myclass {&lt;/span&gt;
&lt;span class="rem"&gt;    zoom: 0.6;&lt;/span&gt;
&lt;span class="rem"&gt;}&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;![endif]--&amp;gt;&lt;/span&gt;

&lt;span class="rem"&gt;&amp;lt;!--[if !IE]&amp;gt;--&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
.myclass {
    -moz-transform: scale(0.6);
    -webkit-transform: scale(0.6);
}
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The css 'zoom' would work for IE and Safari. 'zoom' scales element to the top left of element, and '-moz-transform' and '-webkit-transform' scales to the center. The 'position' property could be further adjusted in browser specific styles so that all browsers display the element at exactly same position after scale!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-4037170251115250619?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/4037170251115250619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/scaling-for-iechromefirefoxsafari.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4037170251115250619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4037170251115250619'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/scaling-for-iechromefirefoxsafari.html' title='Scaling for IE/Chrome/Firefox/Safari'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6781702802717767005</id><published>2011-02-10T20:59:00.001+08:00</published><updated>2011-02-10T21:02:54.993+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Conditional comments</title><content type='html'>&lt;p&gt;Conditional comments only work for IE, but it can be used for deciding whether the browser is IE or not, and include browser specific style sheets.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;&amp;lt;!--[if IE]&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;do something for IE&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;!--[if !IE]&amp;gt;--&amp;gt;&lt;/span&gt;
do something for other browsers
&lt;span class="rem"&gt;&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
	border: 1px solid lightgray;
	padding: 2px 3px;
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Reference: &lt;a href="http://www.quirksmode.org/css/condcom.html"&gt;http://www.quirksmode.org/css/condcom.html&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6781702802717767005?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6781702802717767005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/conditional-comments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6781702802717767005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6781702802717767005'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/conditional-comments.html' title='Conditional comments'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5470578160878600317</id><published>2011-02-10T20:25:00.000+08:00</published><updated>2011-02-10T21:03:24.956+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Chrome minimum font size</title><content type='html'>&lt;p&gt;I find my chrome failed to display my css font size settings. I learned that chrome has a default minimum font size setting, and the solution is to add below syntax:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;-webkit-text-size-adjust:none;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
	border: 1px solid lightgray;
	padding: 2px 3px;
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5470578160878600317?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5470578160878600317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/chrome-minimum-font-size.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5470578160878600317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5470578160878600317'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/02/chrome-minimum-font-size.html' title='Chrome minimum font size'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5068332363260958104</id><published>2011-01-14T20:47:00.001+08:00</published><updated>2011-01-14T20:48:01.935+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>天梯 - 釗峰</title><content type='html'>&lt;object width="560" height="340"&gt;&lt;param name="movie" value="http://www.youtube.com/v/BXHd0Nu_AiU?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/BXHd0Nu_AiU?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;p&gt;《天梯》 &lt;/p&gt;  &lt;p&gt;主唱：釗峰@C AllStar    &lt;br /&gt;作曲：賴映彤@groovision     &lt;br /&gt;填詞：鍾晴     &lt;br /&gt;編曲：Adrian Chan@Sense &amp;amp;賴映彤@groovision     &lt;br /&gt;監製：簡@groovision &lt;/p&gt;  &lt;p&gt;如可 找個荒島    &lt;br /&gt;向未來避開生活中那些苦惱     &lt;br /&gt;如冬天欠電爐 雙手擁抱 可跟天對賭 &lt;/p&gt;  &lt;p&gt;無論有幾高 就如絕路    &lt;br /&gt;隔絕塵俗只想要跟你可終老     &lt;br /&gt;來跨出那地圖 不需好報 都只想你好 &lt;/p&gt;  &lt;p&gt;能共你 沿途來爬天梯 不用忌諱    &lt;br /&gt;中傷流言全悍衛     &lt;br /&gt;留住你 旁人如何話過不可一世     &lt;br /&gt;問我亦無愧 有你可失去我一切 &lt;/p&gt;  &lt;p&gt;幾多對 持續愛到幾多歲    &lt;br /&gt;當生命 仍能為你豁出去     &lt;br /&gt;千夫所指裡 誰理登不登對     &lt;br /&gt;仍挽手歷盡在世間興衰 &lt;/p&gt;  &lt;p&gt;幾多對 能悟到幾多精髓 能撐 下去    &lt;br /&gt;竭力也要為愛盡瘁 抱緊一生未覺累     &lt;br /&gt;前方 仍然大霧     &lt;br /&gt;到懸崖或海邊也許永不知道     &lt;br /&gt;能相擁到白頭 一起偕老 不跟天鬥高 &lt;/p&gt;  &lt;p&gt;前面有幾高 一片荒土    &lt;br /&gt;每步隨著攀登叫雙手都粗糙     &lt;br /&gt;從崎嶇這路途 開墾給你 可走得更好 &lt;/p&gt;  &lt;p&gt;能共你 沿途來爬天梯 黑夜亦亮麗    &lt;br /&gt;於山頭同盟洪海中發誓     &lt;br /&gt;留住你 旁人如何 話過不可一世     &lt;br /&gt;問我亦無愧 有你可以 拆破這天際 &lt;/p&gt;  &lt;p&gt;幾多對 持續愛到幾多歲    &lt;br /&gt;當生命 仍能為你豁出去     &lt;br /&gt;千夫所指裡 誰理登不登對     &lt;br /&gt;仍挽手歷盡在世間興衰 &lt;/p&gt;  &lt;p&gt;幾多對 能悟到幾多精髓 能撐 下去    &lt;br /&gt;竭力也要為愛盡瘁 抱緊一生未覺累 &lt;/p&gt;  &lt;p&gt;握著手 而幸福包圍泥牆簡陋    &lt;br /&gt;牽著走 懷著勇氣至愛得永久 &lt;/p&gt;  &lt;p&gt;幾多對 持續愛到幾多歲    &lt;br /&gt;不轟烈 如何做世界之最     &lt;br /&gt;千夫所指裡 誰理登不登對     &lt;br /&gt;仍挽手歷盡在世間興衰     &lt;br /&gt;幾多對 能悟到幾多精髓 能撐 下去     &lt;br /&gt;竭力也要為愛盡瘁 抱緊一生未覺累 &lt;/p&gt;  &lt;p&gt;幾多對 持續愛到幾多歲    &lt;br /&gt;當生命 仍能為你豁出去&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5068332363260958104?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5068332363260958104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/01/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5068332363260958104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5068332363260958104'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2011/01/blog-post.html' title='天梯 - 釗峰'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1310777271953342387</id><published>2010-12-24T23:05:00.001+08:00</published><updated>2010-12-24T23:05:33.295+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='趨光'/><title type='text'>林俊傑 - 熟能生巧</title><content type='html'>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/O-tFaRSr8AQ?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/O-tFaRSr8AQ?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;p&gt;作詞：林秋離 作曲：林俊傑    &lt;br /&gt;醒著像睡著 躺著像思考 神魂顛倒     &lt;br /&gt;感情太單調 竟然是煩惱 如何是好     &lt;br /&gt;也許來陣風雨 花謝滿地     &lt;br /&gt;黯然神傷的困擾     &lt;br /&gt;可以刺激那顆 渾渾噩噩     &lt;br /&gt;失去了烈火 激情的大腦     &lt;br /&gt;吹風就感冒 淋雨就發燒 有愛就好     &lt;br /&gt;＃我不再逃 空虛日子 這一路都在熬     &lt;br /&gt;也許愛情就是熟能生巧     &lt;br /&gt;你絕對想不到我多渴望     &lt;br /&gt;讓生活染上一些顏料     &lt;br /&gt;是紅橙黃或藍靛紫都好     &lt;br /&gt;一圈一圈的圍繞     &lt;br /&gt;終於能自在的坦誠說愛你     &lt;br /&gt;火一點就燃燒     &lt;br /&gt;怎麼刺激那顆 渾渾噩噩     &lt;br /&gt;失去了烈火 激情的大腦     &lt;br /&gt;吹風就感冒 淋雨就發燒 有愛就好&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1310777271953342387?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1310777271953342387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/12/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1310777271953342387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1310777271953342387'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/12/blog-post.html' title='林俊傑 - 熟能生巧'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6538246744726737429</id><published>2010-11-23T23:29:00.001+08:00</published><updated>2010-11-23T23:33:04.524+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>jQuery</title><content type='html'>&lt;p&gt;jQuery小練習。下拉選單或點圖可以變換人物，下方的文字也會跟著變動。都在client-side完成。&lt;/p&gt;  &lt;center&gt; &lt;div&gt;&lt;select id="charsel"&gt;&lt;/select&gt;&lt;/div&gt; &lt;img id="charimg" border="0"/&gt; &lt;div id="character"&gt;&lt;/div&gt;  &lt;/center&gt;   &lt;script src="https://sites.google.com/site/katagalan/jquery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script&gt;
var charlist = new Array("花媽", "花爸", "橘子", "柚子");
var charoccp = new Array("家庭主婦", "上班族", "高中生", "國中生");

$(document).ready(function(){
    for(var i=0; i&lt;charlist.length; i++)
        $('#charsel').append("&lt;option value="+ i +"&gt;" + charlist[i] + "&lt;/option&gt;");
    getCharacter(Math.round(Math.random()*3 + 1));
});

$('#charimg').click(function(){
    getCharacter(Math.round(Math.random()*3 + 1));
});

$('#charsel').change(function(){
    getCharacter(Number($(this).val())+1);
});

function getCharacter(r){
    $('#charimg').attr('src', 'http://www.ttv.com.tw/drama09/atashinchi/images/cast'+ r +'.gif');
    $('#character').html(charoccp[r-1]);
    $('#charsel').val(r-1);
}
&lt;/script&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6538246744726737429?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6538246744726737429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6538246744726737429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6538246744726737429'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/jquery.html' title='jQuery'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-2935345678735084981</id><published>2010-11-22T23:49:00.001+08:00</published><updated>2010-11-22T23:49:55.083+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>javascript</title><content type='html'>&lt;p&gt;其實蠻好玩的嘛，不知道之前在怕個什麼勁。以下用javascript寫的小功能，隨機generate兩個數字算最大公因數。&lt;/p&gt;  &lt;p&gt;&lt;a id="obj" href="javascript: randgcd();"&gt;&lt;/a&gt;&lt;script type="text/javascript"&gt;
&lt;!--
function gcd(var1, var2){
    while(var2 != 0){
        tmp = var1;
        var1 = var2;
        var2 = tmp % var1;
    }
    return var1;
}
function randgcd(){
    v1 = Math.round(Math.random() * 99999) + 1;
    v2 = Math.round(Math.random() * 99999) + 1;
    o = document.getElementById('obj');
    o.innerHTML = '(' + v1 + ', ' + v2 + ')=' + gcd(v1, v2);
}
randgcd();
--&gt;
&lt;/script&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-2935345678735084981?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/2935345678735084981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2935345678735084981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2935345678735084981'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/javascript.html' title='javascript'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-560115235439632716</id><published>2010-11-20T04:17:00.001+08:00</published><updated>2010-11-20T04:20:25.081+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google App Engine'/><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>A Web App</title><content type='html'>&lt;p&gt;Deployed a simple web app to Google App Engine, using Python. The web app has a form that let users input book name and book price and store data to database. It checks whether user inputs are valid. And it displays all stored data and let users choose the display order.&lt;/p&gt;  &lt;p&gt;It is really amazing to have database functionality without having to maintain a database server.&lt;/p&gt;  &lt;p&gt;feel free to try it and add some new entries on &lt;a href="http://tagtraumapp.appspot.com/" target="_blank"&gt;tagtraumapp.appspot.com&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-560115235439632716?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/560115235439632716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/web-app.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/560115235439632716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/560115235439632716'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/web-app.html' title='A Web App'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6944989188997536069</id><published>2010-11-19T22:00:00.001+08:00</published><updated>2010-11-19T22:01:15.437+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google App Engine'/><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Google App Engine !</title><content type='html'>&lt;p&gt;Which is really cool. Enjoyed the excitement of &lt;a href="http://en.wikipedia.org/wiki/Cloud_computing" target="_blank"&gt;cloud computing&lt;/a&gt; for the first time!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://code.google.com/appengine/docs/python/overview.html" target="_blank"&gt;App Engine Python Overview&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6944989188997536069?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6944989188997536069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/google-app-engine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6944989188997536069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6944989188997536069'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/google-app-engine.html' title='Google App Engine !'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1307331891725983079</id><published>2010-11-12T22:21:00.000+08:00</published><updated>2010-11-12T22:22:47.889+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>周柏豪 - 走狗</title><content type='html'>&lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/8DqUfQYPgvk?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/8DqUfQYPgvk?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;作曲: 張佩瑩    &lt;br /&gt;填詞: 林夕 &lt;/p&gt;  &lt;p&gt;吃我最不喜愛料理 吃到我歡喜    &lt;br /&gt;有了你犧牲我習慣 免惹你生氣     &lt;br /&gt;如果爭執只想討好你 不必講理     &lt;br /&gt;還期望穿衣穿到彷彿 很襯你 &lt;/p&gt;  &lt;p&gt;像你所講隨時要聽候 你都講過愛是終身獻奉    &lt;br /&gt;不計較亦無求 原來未足夠     &lt;br /&gt;勉強遷就 只可加劇你渴求     &lt;br /&gt;依足你任何吩咐 更無權去攔住你拖手 &lt;/p&gt;  &lt;p&gt;誰想到聽講聽教令我個性也生銹    &lt;br /&gt;誰想到只聽你話連自尊也再沒有     &lt;br /&gt;馴服地吠不出口 令你我也看不起我遞上手     &lt;br /&gt;會拖多幾晝 &lt;/p&gt;  &lt;p&gt;像你所講難捱也接受 你都講過愛是堅忍退讓    &lt;br /&gt;將妥協換自由 原來未足夠     &lt;br /&gt;我的溫柔 根本不是你所求     &lt;br /&gt;依足你任何吩咐 更無權去攔住你拖走 &lt;/p&gt;  &lt;p&gt;誰想到聽講聽教令我個性也生銹    &lt;br /&gt;誰想到只聽你話連自尊也再沒有     &lt;br /&gt;馴服地吠不出口 令你我也看不起我     &lt;br /&gt;只敢附和 只懂求和 情感拖得太久 &lt;/p&gt;  &lt;p&gt;誰相信嘔心瀝血令我血性也失守    &lt;br /&gt;明白我賣相全為迎合你醜到未知醜     &lt;br /&gt;誰連賣力討好你令我變了你的狗 命我走 便要走 &lt;/p&gt;  &lt;p&gt;寵你寵到嘔心瀝血令我血性也失守    &lt;br /&gt;明白我賣相全為迎合你醜到未知醜     &lt;br /&gt;誰連賣力討好你令我變了你的狗 若我走 我終於忍夠&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1307331891725983079?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1307331891725983079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post_4860.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1307331891725983079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1307331891725983079'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post_4860.html' title='周柏豪 - 走狗'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3811973011956780463</id><published>2010-11-12T22:19:00.000+08:00</published><updated>2010-11-12T22:20:04.000+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>周柏豪 - 最好不過</title><content type='html'>&lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/L6svani94fo?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/L6svani94fo?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;作曲：陳光榮    &lt;br /&gt;填詞：馮曦妤     &lt;br /&gt;編曲：周柏豪 / 陳光榮     &lt;br /&gt;監製：舒文 / 陳光榮 &lt;/p&gt;  &lt;p&gt;叮囑我小心 千句萬句    &lt;br /&gt;看顧在身邊 一歲又一歲     &lt;br /&gt;生長於小堡壘 是我仍陶醉     &lt;br /&gt;愉快在於 簡單喝汽水 &lt;/p&gt;  &lt;p&gt;走出這溫室 奔向夢想追    &lt;br /&gt;風雨下濕身 走到肉身都破碎     &lt;br /&gt;人大了為何憔悴 愉快為何減退     &lt;br /&gt;太過累 偏偏收到來自你掌心的汽水 &lt;/p&gt;  &lt;p&gt;餘生都不會掉低我 全因有你 荊棘困難撐得過    &lt;br /&gt;當宇宙逆轉過 家裡仍像當初     &lt;br /&gt;磨練過 勞累過 回家最好不過 &lt;/p&gt;  &lt;p&gt;當我又出走 從來沒追究    &lt;br /&gt;當軟弱灰心 誰人像好友     &lt;br /&gt;即使我事事犯錯 體恤我亦肯定我     &lt;br /&gt;安撫我 開心簡單來做我 不必想太多 &lt;/p&gt;  &lt;p&gt;餘生都不會掉低我 全因有你 荊棘困難撐得過    &lt;br /&gt;當宇宙逆轉過 家裡仍像當初     &lt;br /&gt;磨練過 勞累過 回家最好不過 &lt;/p&gt;  &lt;p&gt;餘生都不會掉低我 全因有你 荊棘困難撐得過    &lt;br /&gt;當宇宙逆轉過 家裡仍像當初     &lt;br /&gt;流淚過 沉澱過 回家最好不過&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3811973011956780463?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3811973011956780463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post_12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3811973011956780463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3811973011956780463'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post_12.html' title='周柏豪 - 最好不過'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1415513242257958545</id><published>2010-11-12T22:16:00.000+08:00</published><updated>2010-11-12T22:17:11.912+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>周柏豪 - 乞丐王子</title><content type='html'>&lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/w9jigzh0VQo?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/w9jigzh0VQo?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;作曲：周博賢    &lt;br /&gt;填詞：周博賢     &lt;br /&gt;編曲：周博賢     &lt;br /&gt;監製：周博賢 &lt;/p&gt;  &lt;p&gt;披搭著污穢破碎故衣 執拾著棄置膠袋似失理智    &lt;br /&gt;那灰黑眼窩憂鬱帶點失意 &lt;/p&gt;  &lt;p&gt;生活在下層談何容易 坑伴饅頭被浸濕都不介意    &lt;br /&gt;耐性進食不放肆 &lt;/p&gt;  &lt;p&gt;充當瘋漢半輩子 給笑太過癡 突然被世界注視千萬次    &lt;br /&gt;留言像諷刺 衣著具創意 人氣飆升不止 &lt;/p&gt;  &lt;p&gt;他身處赤貧有誰會在意 他身世永被當玩笑玩意    &lt;br /&gt;他心理變異還是理智 為何全沒鬥志 變餐桌間的事 &lt;/p&gt;  &lt;p&gt;他一切照舊每日繼續試 找生計過活卻未太如意    &lt;br /&gt;身邊每一個都介意 這個乞男兒 討最低工資都不得已 &lt;/p&gt;  &lt;p&gt;出身清苦無財無人事 低學歷卻有不死鳥的意志    &lt;br /&gt;每天工作擔舉洗刷都可以 &lt;/p&gt;  &lt;p&gt;可是現實拿窮人歧視 爭逐上游沒契機灰心喪志    &lt;br /&gt;受壓過度失理智 &lt;/p&gt;  &lt;p&gt;充當瘋漢半輩子給笑太過癡 突然被世界注視千萬次    &lt;br /&gt;留言像諷刺 衣著具創意 連遠方鄉親也知 &lt;/p&gt;  &lt;p&gt;他身處赤貧有誰會在意 他身世永被當玩笑玩意    &lt;br /&gt;他心理變異還是理智 為何全沒鬥志 變餐桌間的事 &lt;/p&gt;  &lt;p&gt;他一切照舊每日繼續試 找生計過活卻未太如意    &lt;br /&gt;身邊每一個都介意 這個乞男兒 討最低工資都不得已 &lt;/p&gt;  &lt;p&gt;世態詭異 雖耕種肯去試 期望會結果實幼稚    &lt;br /&gt;即使滿腔戰意 永不躲懶實幹過日子     &lt;br /&gt;因果已前後倒置 滅貧仍沒有法子 &lt;/p&gt;  &lt;p&gt;他多悲慘哪有誰會在意 他身世秘密當玩笑玩意    &lt;br /&gt;他心理變異還是理智 為何隨地上廁 要窺探得個「知」 &lt;/p&gt;  &lt;p&gt;他穿梭鄉鎮每日拼命試 找生計過活卻遇上敵意    &lt;br /&gt;身邊每位眼光懷疑 憎厭這男兒 討最低工資都不可以&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1415513242257958545?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1415513242257958545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1415513242257958545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1415513242257958545'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/blog-post.html' title='周柏豪 - 乞丐王子'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8198784171928871481</id><published>2010-11-02T23:45:00.001+08:00</published><updated>2010-11-02T23:45:43.375+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Install northwind and pubs sample database on SQL Server 2008</title><content type='html'>&lt;p&gt;I’m pretty new to database. This is how I installed northwind and pubs sample database on SQL Server 2008.&lt;/p&gt;  &lt;p&gt;1. Download “&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en" target="_blank"&gt;SQL2000SampleDb.msi&lt;/a&gt;” and execute the msi file, which will extract files under “C:\SQL Server 2000 Sample Databases”    &lt;br /&gt;2. Run “SQL Server Management Studio” and connect to “Database Engine”    &lt;br /&gt;3. Choose File-&amp;gt;Open-&amp;gt;File and select the “instnwnd.sql” (for northwind database) or “instpubs.sql” (for pubs database) under “C:\SQL Server 2000 Sample Databases” folder.    &lt;br /&gt;4. Click “Execute” on the toolbar or “Query-&amp;gt;Execute” to execute the sql commands.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8198784171928871481?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8198784171928871481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/install-northwind-and-pubs-sample.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8198784171928871481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8198784171928871481'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/11/install-northwind-and-pubs-sample.html' title='Install northwind and pubs sample database on SQL Server 2008'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7632569430462385476</id><published>2010-10-31T20:07:00.001+08:00</published><updated>2010-10-31T20:07:36.238+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>My ACM Solved Problem List</title><content type='html'>&lt;p&gt;Volumn I&lt;/p&gt;  &lt;p&gt;100 - The 3n + 1 problem    &lt;br /&gt;101 - The Blocks Problem     &lt;br /&gt;102 - Ecological Bin Packing     &lt;br /&gt;103 - Stacking Boxes     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-104-arbitrage.html"&gt;104 - Arbitrage&lt;/a&gt;     &lt;br /&gt;105 - The Skyline Problem     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/106-fermat-vs-pythagoras.html"&gt;106 - Fermat vs. Pythagoras&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-108-maximum-sum.html"&gt;108 – Maximum Sum&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-109-scud-buster.html"&gt;109 – SCUD Buster&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-110-meta-loopless-sorts.html"&gt;110 - Meta-Loopless Sorts&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-111-history-grading.html"&gt;111 – History Grading&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-112-tree-summing.html"&gt;112 – Tree Summing&lt;/a&gt;     &lt;br /&gt;113 – Power of Cryptography     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-114-simulation-wizardry.html"&gt;114 – Simulation Wizardry&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-115-climbing-trees.html"&gt;115 – Climbing Trees&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-116-unidirectional-tsp.html"&gt;116 – Unidirectional TSP&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-117-postal-worker-rings-once.html"&gt;117 - The Postal Worker Rings Once&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-118-mutant-flatworld-explorers.html"&gt;118 - Mutant Flatworld Explorers&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-119-greedy-gift-givers.html"&gt;119 - Greedy Gift Givers&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-120-stacks-of-flapjacks.html"&gt;120 - Stacks of Flapjacks&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/08/acm-121-pipe-fitters.html"&gt;121 - Pipe Fitters&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-122-trees-on-level.html"&gt;122 – Trees on the level&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-123-searching-quickly.html"&gt;123 – Searching Quickly&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-124-following-order.html"&gt;124 – Following Orders&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-125-numbering-paths.html"&gt;125 – Numbering Paths&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-126-errant-physicist.html"&gt;126 - The Errant Physicist&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-127-patience.html"&gt;127 - &amp;quot;Accordian&amp;quot; Patience&lt;/a&gt;     &lt;br /&gt;128 - Software CRC     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-129-krypton-factor.html"&gt;129 – Krypton Factor&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-130-roman-roulette.html"&gt;130 – Roman Roulette&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-131-psychic-poker-player.html"&gt;131 - The Psychic Poker Player&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-132-bumpy-objects.html"&gt;132 - Bumpy Objects&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-133-dole-queue.html"&gt;133 – The Dole Queue&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-134-loglan-logical-language.html"&gt;134 - Loglan-A Logical Language&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-135-no-rectangles.html"&gt;135 – No Rectangles&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-136-ugly-numbers.html"&gt;136 – Ugly Numbers&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/09/acm-137-polygons.html"&gt;137 – Polygons&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-138-street-numbers.html"&gt;138 – Street Numbers&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-147-dollars.html"&gt;147 – Dollars&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-166-making-change.html"&gt;166 – Making Change&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Volumn III&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-357-let-me-count-ways.html"&gt;357 – Let Me Count The Ways&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Volumn V&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-562-dividing-coins.html"&gt;562 – Dividing Coins&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Volumn VI&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-624-cd.html"&gt;624 – CD&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-674-coin-change.html"&gt;674 – Coin Change&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Volumn IX&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-990-diving-for-gold.html"&gt;990 – Diving for Gold&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7632569430462385476?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7632569430462385476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/my-acm-solved-problem-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7632569430462385476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7632569430462385476'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/my-acm-solved-problem-list.html' title='My ACM Solved Problem List'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6132267501629585209</id><published>2010-10-31T20:07:00.000+08:00</published><updated>2010-10-31T20:07:12.929+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><title type='text'>list: 2010年看的戲劇</title><content type='html'>&lt;p style="text-align: right"&gt;last update: 2010.10.31&lt;/p&gt;  &lt;table border="0" cellspacing="2" cellpadding="2" width="398"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="94"&gt;&lt;strong&gt;港&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="296"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;＊＊＊＊＊&lt;/td&gt;        &lt;td valign="top" width="296"&gt;公主嫁到(2010)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;＊＊＊＊＊&lt;/td&gt;        &lt;td valign="top" width="296"&gt;疑情別戀(2008)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;＊＊＊&lt;/td&gt;        &lt;td valign="top" width="296"&gt;古靈精探B(2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="296"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;&lt;strong&gt;台&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="296"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;＊＊&lt;/td&gt;        &lt;td valign="top" width="296"&gt;轉角遇到愛(2007)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="296"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;&lt;strong&gt;韓&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="296"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;＊＊＊＊+&lt;/td&gt;        &lt;td valign="top" width="295"&gt;Air City(2007)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;＊＊＊&lt;/td&gt;        &lt;td valign="top" width="295"&gt;Pasta&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="96"&gt;＊＊&lt;/td&gt;        &lt;td valign="top" width="294"&gt;拜託小姐&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="96"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="294"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="96"&gt;&lt;strong&gt;日&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="294"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="96"&gt;＊＊＊＊&lt;/td&gt;        &lt;td valign="top" width="294"&gt;四個謊言/四謊記(2008)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="96"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="294"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6132267501629585209?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6132267501629585209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/list-2010_01.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6132267501629585209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6132267501629585209'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/list-2010_01.html' title='list: 2010年看的戲劇'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3270409044545515237</id><published>2010-10-31T20:06:00.000+08:00</published><updated>2010-11-01T00:40:03.525+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><title type='text'>list: 2010年看的電影</title><content type='html'>&lt;p style="text-align: right"&gt;last update: 2010.11.1 &lt;/p&gt;  &lt;table border="0" cellspacing="3" cellpadding="2"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Shoot ‘Em Up (2007)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;21 (2008)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊&lt;/td&gt;        &lt;td width="263"&gt;The Da Vinci Code (2006)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊+&lt;/td&gt;        &lt;td width="263"&gt;賭神3之少年賭神 (1996)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;雀聖2自摸天后 (2005)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊&lt;/td&gt;        &lt;td width="263"&gt;獨家試愛 (2006)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Inception (2010)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&amp;#160;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&lt;strong&gt;Jul&lt;/strong&gt;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;District 9 (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊&lt;/td&gt;        &lt;td width="263"&gt;The Bounty Hunter (2010)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;72家租客 (2010)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Couples Retreat (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Cloudy with a Chance of Meatballs (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&amp;#160;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&lt;strong&gt;Jun&lt;/strong&gt;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Date Night (2010)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Up in the Air (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;重慶森林 (1994)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;下弦之月 (2004)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&amp;#160;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&lt;strong&gt;May&lt;/strong&gt;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊＋&lt;/td&gt;        &lt;td width="263"&gt;Breakfast at Tiffany's (1961)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&amp;#160;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&lt;strong&gt;Mar&lt;/strong&gt;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;螢火蟲之墓 (火垂るの墓) (1988)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Alice in Wonderland (2010) (3D Version)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Modern Times (1936)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊+&lt;/td&gt;        &lt;td width="263"&gt;The Lovely Bones (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＊＋&lt;/td&gt;        &lt;td width="263"&gt;Artificial Intelligence: AI (2001)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Lilo &amp;amp; Stitch 2: Stitch&amp;#160; Has a Glitch (2005)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Lilo &amp;amp; Stitch (2002)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;Monster Inc. (2001)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＋&lt;/td&gt;        &lt;td width="263"&gt;老港正傳&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;&amp;#160;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="width: 80px" width="87"&gt;&lt;strong&gt;Jan&lt;/strong&gt;&lt;/td&gt;        &lt;td width="263"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊＋&lt;/td&gt;        &lt;td width="263"&gt;2012 (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊&lt;/td&gt;        &lt;td width="263"&gt;(500) Days of Summer (2009)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊&lt;/td&gt;        &lt;td width="263"&gt;得閒飲茶 (2006)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="87"&gt;＊＊＊&lt;/td&gt;        &lt;td width="263"&gt;天水圍日與夜 (2008)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3270409044545515237?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3270409044545515237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/list-2010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3270409044545515237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3270409044545515237'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/list-2010.html' title='list: 2010年看的電影'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8110929952674816218</id><published>2010-10-29T23:16:00.001+08:00</published><updated>2010-10-29T23:16:52.795+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Regex Hero</title><content type='html'>&lt;p&gt;&lt;a href="http://regexhero.net/tester/"&gt;http://regexhero.net/tester/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Great tool to play with and practice regular expression.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8110929952674816218?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8110929952674816218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/regex-hero.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8110929952674816218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8110929952674816218'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/regex-hero.html' title='Regex Hero'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3960964414400097024</id><published>2010-10-22T17:02:00.001+08:00</published><updated>2010-10-22T17:02:02.298+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 674 – Coin Change</title><content type='html'>&lt;p&gt;Another coin change problem, much the same as &lt;a href="http://tagtraumhouse.blogspot.com/2010/10/acm-357-let-me-count-ways.html" target="_blank"&gt;357&lt;/a&gt;. I experimented replacing cin/cout by scanf/printf, and the runtime do reduced dramatically!&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { MAX = 7489, COINS = 5 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; coin[] = {1, 5, 10, 25, 50};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; w[MAX+1] = {};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    w[0] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i=0; i&amp;lt;COINS; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; j=coin[i]; j&amp;lt;=MAX; ++j)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            w[j] += w[j-coin[i]];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;n) != EOF )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        printf(&lt;span style="color: #006080"&gt;&amp;quot;%d\n&amp;quot;&lt;/span&gt;, w[n]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3960964414400097024?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3960964414400097024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-674-coin-change.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3960964414400097024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3960964414400097024'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-674-coin-change.html' title='ACM: 674 – Coin Change'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5863773182692493104</id><published>2010-10-22T16:37:00.001+08:00</published><updated>2010-10-22T16:43:11.208+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 357 – Let Me Count The Ways</title><content type='html'>&lt;p&gt;Straightforward DP coin change problem. To find the number of possible ways that make up certain amount of money.&lt;/p&gt;  &lt;p&gt;My runtime is 0.012. Maybe the way to further reduce runtime is reducing times of i/o?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { MAX = 30000 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; coin[] = {1, 5, 10, 25, 50};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; w[MAX+1] = {};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    w[0] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i=0; i&amp;lt;5; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; j=coin[i]; j&amp;lt;=MAX; ++j)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            w[j] += w[j-coin[i]];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;n) != EOF )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( w[n] == 1 )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            printf(&lt;span style="color: #006080"&gt;&amp;quot;There is only 1 way to produce %d cents change.\n&amp;quot;&lt;/span&gt;, n);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            printf(&lt;span style="color: #006080"&gt;&amp;quot;There are %lld ways to produce %d cents change.\n&amp;quot;&lt;/span&gt;, w[n], n);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5863773182692493104?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5863773182692493104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-357-let-me-count-ways.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5863773182692493104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5863773182692493104'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-357-let-me-count-ways.html' title='ACM: 357 – Let Me Count The Ways'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6804812705815167136</id><published>2010-10-22T13:58:00.001+08:00</published><updated>2010-10-22T13:58:45.099+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 166 – Making Change</title><content type='html'>&lt;p&gt;換零錢的問題，要使用有限量的錢幣去支付一個商品，要找出支付和找錢(假設商家錢幣為無限量)所使用的總錢幣數量為最小。我的做法是，先找出在每一個金額，商家找錢使用的最少錢幣數量。然後根據買家的錢幣組合，找出所有可以支付的金額所使用的最少錢幣數量。最後找出支付+找錢總使用最少的錢幣數量。&lt;/p&gt;  &lt;p&gt;在計算支付的部分，似乎怪怪的，應該有更有效率的做法，但是還想不到怎麼改，繼續研究。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;climits&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { COINS = 6, MAX_CHANGE = 10000 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; coin[] = {1, 2, 4, 10, 20, 40};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; p, q, &lt;span style="color: #008000"&gt;//price&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        w[COINS], &lt;span style="color: #008000"&gt;//wallet&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        change[MAX_CHANGE+1]; &lt;span style="color: #008000"&gt;//change&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j, k, m, sum;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    change[0] = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=1; i&amp;lt;=MAX_CHANGE; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        change[i] = INT_MAX;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;COINS; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=coin[i]; j&amp;lt;=MAX_CHANGE; j++)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            change[j] = min(change[j-coin[i]]+1, change[j]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;(1){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        sum = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;COINS; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;w[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            sum += w[i] * coin[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( sum == 0 ) &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d.%d&amp;quot;&lt;/span&gt;, &amp;amp;p, &amp;amp;q);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        p = (p*100+q)/5;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;* pay = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*)malloc((sum+1) * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;* use = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*)malloc((sum+1) * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( pay == NULL || use == NULL ) exit(1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        pay[0] = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=1; i&amp;lt;=sum; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            pay[i] = INT_MAX;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;COINS; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=1; j&amp;lt;=coin[i]; ++j){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                m = w[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(k=j; k&amp;lt;=sum; k+=coin[i]){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( pay[k] != INT_MAX ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        m = w[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( k &amp;lt; coin[i] ){ &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( m &amp;gt; 0 ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        pay[k] = pay[k-coin[i]] + 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        --m;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                }&lt;span style="color: #008000"&gt;//k&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;span style="color: #008000"&gt;//j&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            memset(use, 0, (sum+1) * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=coin[i]; (j&amp;lt;=sum) &amp;amp;&amp;amp; (use[j-coin[i]] &amp;lt; w[i]) ; ++j){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( (pay[j-coin[i]] != INT_MAX) &amp;amp;&amp;amp; (pay[j-coin[i]]+1 &amp;lt;= pay[j]) ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    pay[j] = pay[j-coin[i]] + 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    use[j] = use[j-coin[i]] + 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;span style="color: #008000"&gt;//i: coins&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; total = INT_MAX;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=p; i&amp;lt;=sum; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( pay[i] != INT_MAX )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                total = min(pay[i]+change[i-p], total);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        printf(&lt;span style="color: #006080"&gt;&amp;quot;%3d\n&amp;quot;&lt;/span&gt;, total);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        free(pay);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        free(use);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6804812705815167136?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6804812705815167136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-166-making-change.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6804812705815167136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6804812705815167136'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-166-making-change.html' title='ACM: 166 – Making Change'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8935104649813634271</id><published>2010-10-20T22:14:00.001+08:00</published><updated>2010-10-20T22:14:25.231+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 147 - Dollars</title><content type='html'>&lt;p&gt;也是一直想學的DP換零錢問題，很有趣。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;注意浮點數誤差的問題&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.algorithmist.com/index.php/Coin_Change" target="_blank"&gt;Coin Change&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { MAX = 300 * 100 / 5, COINS = 11 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; coin[] = {1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000}; &lt;span style="color: #008000"&gt;//value*100/5&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; r[MAX+1];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;=MAX; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        r[i] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=1; i&amp;lt;COINS; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=coin[i]; j&amp;lt;=MAX; ++j)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            r[j] = r[j-coin[i]] + r[j];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( (scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d.%d&amp;quot;&lt;/span&gt;, &amp;amp;i, &amp;amp;j) != EOF) &amp;amp;&amp;amp; (i+j != 0) )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        printf(&lt;span style="color: #006080"&gt;&amp;quot;%3d.%02d%17lld\n&amp;quot;&lt;/span&gt;, i, j, r[(i*100+j)/5]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8935104649813634271?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8935104649813634271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-147-dollars.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8935104649813634271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8935104649813634271'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-147-dollars.html' title='ACM: 147 - Dollars'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8989239952257502586</id><published>2010-10-20T22:07:00.001+08:00</published><updated>2010-10-20T22:07:26.261+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 624 - CD</title><content type='html'>&lt;p&gt;Straightforward 0/1 Knapsack problem. Tried malloc, memset, free in 2D array.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { TRACK = 30 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n, t, d[TRACK];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d%d&amp;quot;&lt;/span&gt;, &amp;amp;n, &amp;amp;t) != EOF ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;t; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;d[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//malloc&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;** pick = (&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;**)malloc(t * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;*));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;t; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            pick[i] = (&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;*)malloc((n+1) * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;* tape = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*)malloc((n+1) * &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( pick == NULL || tape == NULL )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            exit(1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;t; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            memset(pick[i], 0, (n+1)*&lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        memset(tape, 0, (n+1)*&lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=t-1; i&amp;gt;=0; --i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=n; j&amp;gt;=d[i]; --j){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( tape[j-d[i]]+d[i] &amp;gt; tape[j] ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    tape[j] = tape[j-d[i]] + d[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    pick[i][j] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;span style="color: #008000"&gt;//j&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;span style="color: #008000"&gt;//i&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0, j=n; i&amp;lt;t; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( pick[i][j] ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                printf(&lt;span style="color: #006080"&gt;&amp;quot;%d &amp;quot;&lt;/span&gt;, d[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                j -= d[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        printf(&lt;span style="color: #006080"&gt;&amp;quot;sum:%d\n&amp;quot;&lt;/span&gt;, tape[n]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//free&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;t; ++i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            free(pick[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        free(pick);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        free(tape);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8989239952257502586?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8989239952257502586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-624-cd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8989239952257502586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8989239952257502586'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-624-cd.html' title='ACM: 624 - CD'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7943166918520984252</id><published>2010-10-20T01:19:00.001+08:00</published><updated>2010-10-20T01:19:53.030+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 990 – Diving for Gold</title><content type='html'>&lt;p&gt;也是0/1 Knapsack Problem，要輸出最後「背包」放入物品的總價值、物品數量，和輸出被放入的所有物品。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { CAPACITY = 1000, TREASURE = 30 };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; t, w, n, d[TREASURE], td[TREASURE], v[TREASURE];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j, mval[CAPACITY+1], items[CAPACITY+1];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; grab[TREASURE][CAPACITY+1], flag = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d%d%d&amp;quot;&lt;/span&gt;, &amp;amp;t, &amp;amp;w, &amp;amp;n) != EOF ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;n; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d%d&amp;quot;&lt;/span&gt;, &amp;amp;d[i], &amp;amp;v[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            td[i] = d[i] * 3 * w;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        memset(mval, 0, &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(mval));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        memset(items, 0, &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(items));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        memset(grab, 0, &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(grab));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=n; i&amp;gt;=0; --i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=t; j&amp;gt;=td[i]; --j){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( mval[j-td[i]]+v[i] &amp;gt; mval[j] ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    mval[j] = mval[j-td[i]] + v[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    items[j] = items[j-td[i]] + 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    grab[i][j] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;span style="color: #008000"&gt;//j&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;span style="color: #008000"&gt;//i&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( flag ) printf(&lt;span style="color: #006080"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; flag = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        printf(&lt;span style="color: #006080"&gt;&amp;quot;%d\n%d\n&amp;quot;&lt;/span&gt;, mval[t], items[t]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0, j=t; i&amp;lt;n; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( grab[i][j] ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                printf(&lt;span style="color: #006080"&gt;&amp;quot;%d %d\n&amp;quot;&lt;/span&gt;, d[i], v[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                j -= td[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7943166918520984252?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7943166918520984252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-990-diving-for-gold.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7943166918520984252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7943166918520984252'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-990-diving-for-gold.html' title='ACM: 990 – Diving for Gold'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8536200999234662298</id><published>2010-10-20T01:08:00.001+08:00</published><updated>2010-10-20T01:08:57.428+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 562 – Dividing Coins</title><content type='html'>&lt;p&gt;一直想學的背包問題，這題是0/1 Knapsack Problem。要把一堆面額不等的錢幣分成兩堆，使得兩堆錢幣總額的差距最小，輸出兩堆的差額。&lt;/p&gt;  &lt;p&gt;在用Knapsack的做法之前還是先嘗試了一下greedy method，想看看在什麼情況greedy method會失敗。想法是：把錢幣由大排到小，從最大的開始，分給A、B，若A&amp;gt;B，就分給B，否則就分給A。這個做法在有些情況可以找到正確答案，但這個例子就不行：{50, 50, 49, 49, 48, 48, 2}。用這個做法會得到&lt;/p&gt;  &lt;p&gt;A:{50, 49, 48, 2}    &lt;br /&gt;B:{50, 49, 48}&lt;/p&gt;  &lt;p&gt;最小差距為2，但其實另一種分法就可以平分，A:{50, 49, 49}, B:{50, 48, 48, 2}，差距為0。&lt;/p&gt;  &lt;p&gt;所以還是要用背包問題的DP做法，把錢幣盡量湊到總額的一半。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCES&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://caterpillar.onlyfun.net/Gossip/AlgorithmGossip/KnapsackProblem.htm" target="_blank"&gt;良葛格學習筆記&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.csie.ntnu.edu.tw/~u91029/DynamicProgramming.html#a9" target="_blank"&gt;演算法筆記&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; { MAX_M = 100, MAX_VAL = 500, MAX_SUM = MAX_VAL*MAX_M };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n, m, c[MAX_M];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j, t, sum, half, p[MAX_SUM+1] = {};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;n);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(; n&amp;gt;0; --n){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;m);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        sum = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;m; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            scanf(&lt;span style="color: #006080"&gt;&amp;quot;%d&amp;quot;&lt;/span&gt;, &amp;amp;c[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            sum += c[i];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        half = sum / 2;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=0; i&amp;lt;m; ++i) &lt;span style="color: #008000"&gt;//all coins&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=half; j&amp;gt;=c[i]; --j)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                p[j] = max(p[j], p[j-c[i]]+c[i]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        cout &amp;lt;&amp;lt; (((t = 2 * p[half] - sum) &amp;gt; 0) ? t : -1*t ) &amp;lt;&amp;lt; endl;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        memset(p, 0, &lt;span style="color: #0000ff"&gt;sizeof&lt;/span&gt;(p));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;span style="color: #008000"&gt;//n inputs&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8536200999234662298?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8536200999234662298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-562-dividing-coins.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8536200999234662298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8536200999234662298'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-562-dividing-coins.html' title='ACM: 562 – Dividing Coins'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8795160936953841985</id><published>2010-10-07T23:43:00.001+08:00</published><updated>2010-10-12T22:47:16.516+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 138 – Street Numbers</title><content type='html'>&lt;p&gt;這題寫出來超開心！&lt;/p&gt;  &lt;p&gt;要找到n, k，使得1 + 2 + 3 + … + (k-1) = (k+1) + (k+2) + … + n。這題是no input，要傳回前10對n, k。題目已經給出前2對，第一對是(6, 8)，因為1+2+3+4+5 = 7 + 8 = 15。&lt;/p&gt;  &lt;p&gt;我一開始的做法是，left從1開始累加，當累加(k-1)時，right就從(k+1)開始往上加，直到right&amp;gt;=left為止，若right==left，則找到一對(n, k)。這個方法可以找到正確答案，但實在跑太久，我讓他跑了一個小時，才找到第8對。&lt;/p&gt;  &lt;p&gt;想著想著突然間豁然開朗，發現更有效率的方法。新的想法是，已知第一對(n, k)，即是知道一對相等的left, right，從這裡開始。k每加一，left加入(k-1)，因為要納入原本的分隔點(k-1)，而right則減掉k，因為要扣掉新的分隔點k。接著right再從n+1開始累加上去，直到right&amp;gt;=left為止，若right==left，則找到一對(n, k)。然後n, k, left, right的值都保留繼續累加使用。&lt;/p&gt;  &lt;p&gt;沒想到這樣的做法竟然快了非常多，馬上答案就出來了！在看到第10對(n, k)的時候簡直太感動了。用這個做法就不用先把答案算出來然後上傳hard code了，Runtime是0.328。&lt;/p&gt;  &lt;p&gt;說回這個問題，1 + 2 + 3 + … + (k-1) = (k+1) + (k+2) + … + n，看起來好像是蠻容易滿足的條件，但第10對(n, k)竟然已經是8位數字了！數字真神奇啊。另外，查了資料也發現這個問題可以用數論的Pell’s equation直接求解，但看&lt;a href="http://mathworld.wolfram.com/PellEquation.html" target="_blank"&gt;Wolfram Mathworld&lt;/a&gt;和&lt;a href="http://en.wikipedia.org/wiki/Pell%27s_equation" target="_blank"&gt;Wikipedia&lt;/a&gt;都看不太懂，希望有天可以了解。&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;unsigned&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; &lt;span style="color: #0000ff"&gt;long&lt;/span&gt; k, n, count, left, right;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    printf(&lt;span style="color: #006080"&gt;&amp;quot;%10d%10d\n%10d%10d\n&amp;quot;&lt;/span&gt;, 6, 8, 35, 49);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(k=36, n=50, count=0, left=595, right=595; count!=8; ++k){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        left += (k - 1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        right -= k;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(; right&amp;lt;left; ++n)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            right += n;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( left == right ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            printf(&lt;span style="color: #006080"&gt;&amp;quot;%10llu%10llu\n&amp;quot;&lt;/span&gt;, k, n-1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            ++count;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8795160936953841985?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8795160936953841985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-138-street-numbers.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8795160936953841985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8795160936953841985'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-138-street-numbers.html' title='ACM: 138 – Street Numbers'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7278583255784484722</id><published>2010-10-07T16:13:00.000+08:00</published><updated>2010-10-07T16:26:33.719+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 136 – Ugly Numbers</title><content type='html'>&lt;p&gt;Ugly number 是質因數只有2或3或5的數字。這題要找出第1500個ugly number。&lt;/p&gt;  &lt;p&gt;原本只是單純的一個數字一個數字檢查質因數，直到找到第1500個ugly number為止，但雖然可以找到正確答案，卻會花很久的時間。查了一下討論區，才恍然大悟可以直接用2,3,5去生成倍數，也想出來了生成的方法，真開心！&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;climits&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main(){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; u[1500], p[3] = {2, 3, 5};&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i, j, k, t;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    u[0] = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(i=1; i&amp;lt;1500; ++i){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        u[i] = INT_MAX;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(j=0; j&amp;lt;3; ++j){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;for&lt;/span&gt;(k=0; (t = u[k] * p[j]) &amp;lt;= u[i-1]; ++k);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( t &amp;lt; u[i] )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                u[i] = t;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;span style="color: #008000"&gt;//j: 2,3,5&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;span style="color: #008000"&gt;//i: i'th ugly number&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    printf(&lt;span style="color: #006080"&gt;&amp;quot;The 1500'th ugly number is %d.\n&amp;quot;&lt;/span&gt;, u[i-1]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CODE (naive and slow version)&lt;/strong&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; otherprime(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( n%2 == 0 )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    n /= 2;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( n%3 == 0 )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    n /= 3;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( n%5 == 0 )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    n /= 5;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( n == 1 )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; false;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; true;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; main() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; n = 1; &lt;span style="color: #008000"&gt;//start from 2&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; count = 1; &lt;span style="color: #008000"&gt;//the 1st ugly number is 1&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;while&lt;/span&gt;( count &amp;lt; 1500 ){ &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ++n;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( (n % 2 == 0) || (n % 3 == 0) || (n % 5 == 0) ){&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;      &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( !otherprime(n) )&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        ++count;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  cout &amp;lt;&amp;lt; n &amp;lt;&amp;lt; endl;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;  &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7278583255784484722?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7278583255784484722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-136-ugly-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7278583255784484722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7278583255784484722'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-136-ugly-numbers.html' title='ACM: 136 – Ugly Numbers'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-570892628933970524</id><published>2010-10-06T22:01:00.001+08:00</published><updated>2010-10-06T22:01:39.002+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 135 – No Rectangles</title><content type='html'>&lt;p&gt;要找到規律，畫一個k=6的解，就可以找到規律了。不過雖然找到了規律，卻還不知道為什麼規律是這樣。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;

int main(){
  int k, n;
  int block; //k-1
  bool flag = false;
  
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;k) != EOF ) {
    if( flag )
      printf(&amp;quot;\n&amp;quot;);
    else
      flag = true;
      
    n = k * k - k + 1;
    block = k - 1;
    
    int i, j, t, p;
    int line = 0; //count total lines printed
    int starter = 1; //first number of every line
    int count = 2;
    
    //print first k lines
    for(i=0; i&amp;lt;k; ++i, ++line){
      printf(&amp;quot;%d&amp;quot;, starter);
      for(j=1; j&amp;lt;k; ++j, ++count){
        printf(&amp;quot; %d&amp;quot;, count);
      }//j: k marks
      printf(&amp;quot;\n&amp;quot;);
    }//i: line
    
    //print (k-1) blocks, each block has (k-1) lines
    for(i=0; i&amp;lt;block &amp;amp;&amp;amp; line&amp;lt;=n; ++i){
      ++starter;
      for(j=0; j&amp;lt;block; ++j, ++line){
        printf(&amp;quot;%d&amp;quot;, starter);
        p = j;
        printf(&amp;quot; %d&amp;quot;, k+p+1);
        for(t=(k+block+1); t&amp;lt;n; t+=block){
          p = (p + i) % block;
          printf(&amp;quot; %d&amp;quot;, t+p);
        }//t: go to starting point of each block
        printf(&amp;quot;\n&amp;quot;);
      }//j: lines
    }//i: blocks of lines
  }
  
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-570892628933970524?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/570892628933970524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-135-no-rectangles.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/570892628933970524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/570892628933970524'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/acm-135-no-rectangles.html' title='ACM: 135 – No Rectangles'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8893157171186698316</id><published>2010-10-03T16:52:00.001+08:00</published><updated>2010-10-03T16:58:45.129+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Projects'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>Java Project: Reversi</title><content type='html'>&lt;p&gt;黑白棋遊戲。可兩人對戰或一個玩家跟電腦玩，也可以看電腦跟電腦瞬間對決。目前寫的AI只是單純選擇可以翻轉最多對手棋子的下一步，因此還蠻容易贏這個AI的。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;功能：&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;1. 提供兩個玩家、一個玩家和一個電腦玩家、或兩個電腦玩家進行黑白棋遊戲。   &lt;br /&gt;2. 遊戲進行時，當滑鼠移動到可以下子的格點，顯示圖示提示。    &lt;br /&gt;3. 遊戲進行時，即時顯示目前下子方(黑子或白子)和目前分數。    &lt;br /&gt;4. 可隨時改變玩家設定(選擇由電腦或人下棋)，設定將在下一次輪到該顏色棋子下棋時執行。    &lt;br /&gt;5. 可隨時開啟新遊戲。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;執行畫面：&lt;/strong&gt;&lt;/p&gt;  &lt;p align="center"&gt;&lt;img src="http://lh3.ggpht.com/_GF1-Pb0l-WE/TKhDGFt-k9I/AAAAAAAAEnU/bDAjoas8018/Reversi_v_1_0_01.jpg" width="250" height="296" /&gt;     &lt;br /&gt;&lt;img src="http://lh5.ggpht.com/_GF1-Pb0l-WE/TKhDGRtrg7I/AAAAAAAAEnY/zjZObZMKEp4/Reversi_v_1_0_02.jpg" width="250" height="297" /&gt;     &lt;br /&gt;&lt;img src="http://lh4.ggpht.com/_GF1-Pb0l-WE/TKhDGVWKA0I/AAAAAAAAEnc/u3dUuEztxTY/Reversi_v_1_0_03.jpg" width="250" height="297" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;檔案下載：&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://sites.google.com/site/katagalan/Reversi.rar"&gt;Reversi_v_1_0.rar (155 kb)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8893157171186698316?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8893157171186698316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/java-project-reversi.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8893157171186698316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8893157171186698316'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/java-project-reversi.html' title='Java Project: Reversi'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_GF1-Pb0l-WE/TKhDGFt-k9I/AAAAAAAAEnU/bDAjoas8018/s72-c/Reversi_v_1_0_01.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3469235316317481357</id><published>2010-10-01T20:42:00.000+08:00</published><updated>2010-10-01T20:56:47.452+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Projects'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>Java Project: SimplePad</title><content type='html'>&lt;p&gt;簡單的記事本軟體！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;功能：&lt;/strong&gt;     &lt;br /&gt;1. 可以選單或快速鍵執行開啟、儲存純文字檔案。     &lt;br /&gt;2. 開啟檔案或儲存檔案後，檔名顯示在標題列。     &lt;br /&gt;3. 可以選單或快速鍵執行剪下、複製、貼上功能。     &lt;br /&gt;4. 可開啟或關閉自動換行(Line Wrap)。    &lt;br /&gt;5. 可以讀寫中文！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;執行畫面：&lt;/strong&gt;&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="400"&gt;         &lt;p&gt;&lt;img src="http://lh4.ggpht.com/_GF1-Pb0l-WE/TKXPKGnGknI/AAAAAAAAEmg/zE4Dbr85IJk/SimplePad01.jpg" width="300" height="246" /&gt; &lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="400"&gt;&lt;img src="http://lh6.ggpht.com/_GF1-Pb0l-WE/TKXZ4wCdXII/AAAAAAAAEnM/_4NJYYdsiMk/SimplePad02.jpg" width="300" height="246" /&gt; &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="400"&gt;&lt;img src="http://lh4.ggpht.com/_GF1-Pb0l-WE/TKXZ5CF6A1I/AAAAAAAAEnQ/00dacS5ucRg/SimplePad03.jpg" width="300" height="246" /&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;檔案下載：&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://sites.google.com/site/katagalan/SimplePad.rar"&gt;SimplePad.rar (148 kb)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3469235316317481357?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3469235316317481357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/java-simplepad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3469235316317481357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3469235316317481357'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/10/java-simplepad.html' title='Java Project: SimplePad'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_GF1-Pb0l-WE/TKXPKGnGknI/AAAAAAAAEmg/zE4Dbr85IJk/s72-c/SimplePad01.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1599261132889616141</id><published>2010-09-28T15:43:00.001+08:00</published><updated>2010-10-01T20:58:27.513+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Projects'/><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title type='text'>Java Project: Tic Tac Toe</title><content type='html'>&lt;p&gt;非常陽春的圈圈叉叉小遊戲，可以兩個人玩，但沒有電腦玩家。&lt;/p&gt;  &lt;p&gt;練習和試驗一些基本的JAVA語法、事件，玩玩Swing的component。用JSmooth把檔案包成exe執行檔，可以直接在windows執行。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;功能：      &lt;br /&gt;&lt;/strong&gt;1. 兩個玩家玩井字遊戲。當獲勝者出現顯示獲勝者，若至遊戲結束皆無獲勝者則顯示&amp;quot;Draw&amp;quot;。     &lt;br /&gt;2. 隨時可按&amp;quot;New Game&amp;quot;或Alt+n開始新遊戲。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;執行畫面：&lt;/strong&gt;&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;img src="http://lh4.ggpht.com/_GF1-Pb0l-WE/TKGWFyTjkMI/AAAAAAAAEmU/xBV927Cz7bg/TicTacToe01.jpg" width="150" height="251" /&gt; &lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;img src="http://lh6.ggpht.com/_GF1-Pb0l-WE/TKGWF5E5TGI/AAAAAAAAEmY/0q53RiaZ2FU/TicTacToe02.jpg" width="150" height="251" /&gt; &lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;img src="http://lh3.ggpht.com/_GF1-Pb0l-WE/TKGWFzUuMKI/AAAAAAAAEmc/gg4mYaeV2qI/TicTacToe03.jpg" width="150" height="251" /&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;檔案下載：      &lt;br /&gt;&lt;/strong&gt;&lt;a href="https://sites.google.com/site/katagalan/TicTacToe.rar"&gt;TicTacToe.rar (149 kb)&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1599261132889616141?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1599261132889616141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/java-tic-tac-toe.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1599261132889616141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1599261132889616141'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/java-tic-tac-toe.html' title='Java Project: Tic Tac Toe'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_GF1-Pb0l-WE/TKGWFyTjkMI/AAAAAAAAEmU/xBV927Cz7bg/s72-c/TicTacToe01.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5933474876818213077</id><published>2010-09-18T14:54:00.000+08:00</published><updated>2010-09-18T14:55:12.775+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 134 - Loglan-A Logical Language</title><content type='html'>&lt;p&gt;這題要用給定的文法規則，去檢查輸入的句子是否符合文法。我直接暴力的遞迴...&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIP&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;雖然題目寫&amp;quot;You can assume that all words will be correctly formed&amp;quot;，但實際上加了判斷不和語法的單字才拿到AC。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
using namespace std;

enum { A, MOD, BA, DA, LA, NAM, PREDA };

vector&amp;lt;int&amp;gt; loglan;
int n;

bool vowel(char c){
  return ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' );
}

int convert_loglan(string s, int n){
  if( !vowel( s[n-1] ) ) return NAM;
  if( n == 1 ) return A;
  if( n == 2 ){
    switch( s[0] ){
      case 'g': return MOD;
      case 'b': return BA;
      case 'd': return DA;
      case 'l': return LA;
    }
  }
  if( n==5 &amp;amp;&amp;amp; (( !vowel(s[0]) &amp;amp;&amp;amp; !vowel(s[1]) &amp;amp;&amp;amp; vowel(s[2]) &amp;amp;&amp;amp; !vowel(s[3]) &amp;amp;&amp;amp; vowel(s[4]) ) ||
   ( !vowel(s[0]) &amp;amp;&amp;amp; vowel(s[1]) &amp;amp;&amp;amp; !vowel(s[2]) &amp;amp;&amp;amp; !vowel(s[3]) &amp;amp;&amp;amp; vowel(s[4]) )) )
    return PREDA;
  return NAM;
}

bool predstring(int st, int ed){
  if( st == ed )
    return (loglan[st] == PREDA); //&amp;quot;PREDA&amp;quot;
  return (loglan[ed] == PREDA &amp;amp;&amp;amp; predstring(st, ed-1)); //&amp;quot;&amp;lt;predstring&amp;gt; PREDA&amp;quot;
}

bool verbpred(int st, int ed){
  return (loglan[st] == MOD &amp;amp;&amp;amp; predstring(st+1, ed)); //&amp;quot;MOD &amp;lt;predstring&amp;gt;&amp;quot;
}

bool predname(int st, int ed){
  if( st == ed )
    return (loglan[st] == NAM); //&amp;quot;NAM&amp;quot;
  return (loglan[st] == LA &amp;amp;&amp;amp; predstring(st+1, ed)); //&amp;quot;LA &amp;lt;predstring&amp;gt;&amp;quot;
}

bool preds(int st, int ed){
  for(int i=st+1; i&amp;lt;ed; ++i){
    if( loglan[i] == A ){
      return (preds(st, i-1) &amp;amp;&amp;amp; preds(i+1, ed)); //&amp;quot;&amp;lt;preds&amp;gt; A &amp;lt;predstring&amp;gt; -&amp;gt; &amp;lt;preds&amp;gt; A &amp;lt;preds&amp;gt;&amp;quot;
    }
  }
  return predstring(st, ed); //&amp;quot;&amp;lt;predstring&amp;gt;&amp;quot;
}

bool statement(void){
  for(int i=1; i&amp;lt;n; ++i){
    if( loglan[i] == MOD ){
      bool pv = predname(0, i-1) &amp;amp;&amp;amp; verbpred(i, n-1); //&amp;quot;&amp;lt;predname&amp;gt;&amp;lt;verbpred&amp;gt;&amp;quot;
      bool pvp = 0;
      for(int j=i+1; j&amp;lt;n-1; ++j)
        pvp += (predname(0, i-1) &amp;amp;&amp;amp; verbpred(i, j) &amp;amp;&amp;amp; predname(j+1, n-1)); //&amp;quot;&amp;lt;predname&amp;gt;&amp;lt;verbpred&amp;gt;&amp;lt;predname&amp;gt;&amp;quot;
      return (pvp || pv);
    }
  }
  return 0;
}

bool predclaim(void){
  if( loglan[0] == DA ){
    return preds(1, n-1); //&amp;quot;DA &amp;lt;preds&amp;gt;&amp;quot;
  }
  for(int i=1; i&amp;lt;n; ++i){
    if( loglan[i] == BA )
      return (predname(0, i-1) &amp;amp;&amp;amp; preds(i+1, n-1)); //&amp;quot;&amp;lt;predname&amp;gt; BA &amp;lt;preds&amp;gt;&amp;quot;
  }
  return 0;
}

bool sentence(void){
  return ( statement() || predclaim() );
}

int main(){
  string s;
  while( (cin &amp;gt;&amp;gt; s) &amp;amp;&amp;amp; (s[0] != '#') ){
    int len = s.size();
    if( s[len-1] == '.' ){
      s.erase(len-1);
      loglan.push_back( convert_loglan(s, len-1) );
      n = loglan.size();
      cout &amp;lt;&amp;lt; (sentence() ? &amp;quot;Good&amp;quot; : &amp;quot;Bad!&amp;quot;) &amp;lt;&amp;lt; endl;
      //initialize
      loglan.clear();
    }
    else
      loglan.push_back( convert_loglan(s, len) );
  }//while
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5933474876818213077?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5933474876818213077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-134-loglan-logical-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5933474876818213077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5933474876818213077'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-134-loglan-logical-language.html' title='ACM: 134 - Loglan-A Logical Language'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6631029536662042432</id><published>2010-09-17T21:18:00.000+08:00</published><updated>2010-09-18T05:39:11.963+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 133 – The Dole Queue</title><content type='html'>&lt;p&gt;simulation，類似Josephus problem，照著規則模擬。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;

#define MAX 20

int main(){
  int n, k, m;
  bool a[MAX];
  
  while( scanf(&amp;quot;%d%d%d&amp;quot;, &amp;amp;n, &amp;amp;k, &amp;amp;m) != EOF ){
    if( n==0 &amp;amp;&amp;amp; k==0 &amp;amp;&amp;amp; m==0 )
      break;
    
    for(int i=0; i&amp;lt;n; ++i)
      a[i] = 1;
    
    bool printed = 0;
    int i = -1, j = n, left = n;
    int cnt_k, cnt_m;
    while( left &amp;gt; 0 ){
      cnt_k = cnt_m = 0;
      while( cnt_k != k ){
        i = (i+1)%n;
        if( a[i] )
          ++cnt_k;
      }
      while( cnt_m != m ){
        j = (j+n-1)%n;
        if( a[j] )
          ++cnt_m;
      }
      
      if( printed )
        printf(&amp;quot;,&amp;quot;);
      else
        printed = 1;
        
      if( i == j ){
        a[i] = 0;
        --left;
        printf(&amp;quot;%3d&amp;quot;, i+1);
      }
      else{
        a[i] = a[j] = 0;
        left -= 2;
        printf(&amp;quot;%3d%3d&amp;quot;, i+1, j+1);
      }
    }//killing
    printf(&amp;quot;\n&amp;quot;);
  }//while
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6631029536662042432?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6631029536662042432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-133-dole-queue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6631029536662042432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6631029536662042432'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-133-dole-queue.html' title='ACM: 133 – The Dole Queue'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-635992791978169567</id><published>2010-09-17T19:49:00.001+08:00</published><updated>2010-09-17T19:49:49.400+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 137 - Polygons</title><content type='html'>&lt;p&gt;寫完132，打鐵趁熱繼續寫geometry的題目。這題很複雜，但要解決的問題很清楚，就是求兩個凸多邊形的非交集的面積(xor, 異域)。&lt;/p&gt;  &lt;p&gt;&lt;img height="110" src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Venn0110.svg/384px-Venn0110.svg.png" width="150" /&gt; &lt;/p&gt;  &lt;p&gt;我的算法如下：    &lt;br /&gt;A: 第一個凸多邊形點集合     &lt;br /&gt;B: 第二個凸多邊形點集合     &lt;br /&gt;C: A,B交集部分的點集合(初始為空集合)     &lt;br /&gt;    &lt;br /&gt;1. 檢查A的每一個點，若落在B內部或邊上即將該點加入C。     &lt;br /&gt;2. 檢查B的每一個點，若落在A內部或邊上即將該點加入C。     &lt;br /&gt;3. 檢查A的每一邊，對B的每一邊逐邊檢查是否可以相交，若可相交即求交點，將交點加入C。     &lt;br /&gt;4. A,B交集求畢，將C集合的點逆時針排序。     &lt;br /&gt;5. 輸出異域面積為 (A + B – C) – C = A + B - 2C&lt;/p&gt;  &lt;p&gt;實作方法&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;檢查P點是否落在圖形內部或邊上&lt;/strong&gt;     &lt;br /&gt;逆時針檢查圖形的每一點，若「每一點到下一點的向量」與「每一點至P點的向量」皆為逆時針旋轉(外積&amp;gt;0)，則P點在圖型內部。當外積=0時，P點在圖形邊上。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;檢查線段P1P2與P3P4是否相交      &lt;br /&gt;&lt;/strong&gt;單純用外積檢查兩線段是否互相跨立。     &lt;br /&gt;當 (P1P2 x P1P3)*(P1P2 x P1P4) &amp;lt; 0 時代表P3, P4分別在線段P1P2的兩端，故外積異號。     &lt;br /&gt;當 (P3P4 x P3P1)*(P3P4 x P3P2) &amp;lt; 0 時代表P1, P2分別在線段P3P4的兩端，故外積異號。     &lt;br /&gt;當兩者皆成立時，線段P1P2與線段P3P4相交。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;相交線段求交點&lt;/strong&gt;     &lt;br /&gt;參考「&lt;a href="http://www.cnblogs.com/devymex/archive/2010/08/19/1803885.html"&gt;平面內兩條線段的位置關係判定及交點求解&lt;/a&gt;」，用向量法求解，只需用到一次除法，減少精確度的問題。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;點逆時針排序&lt;/strong&gt;     &lt;br /&gt;先找最左下方的點，其他的點對該點做逆時針的極角排序。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;凸多邊形面積&lt;/strong&gt;     &lt;br /&gt;&lt;img src="http://2.bp.blogspot.com/_GF1-Pb0l-WE/TJNPi-jR79I/AAAAAAAAEl4/P00JPCtkEgo/s320/polygon-area.png" /&gt;&amp;#160; &lt;br /&gt;起點與終點必須為同一個點，即X0Y0 = XnYn，而所有的點必須照順時針或逆時針排序，當點為順時針排序時，總和為負數，逆時針排序時，總和為正數，但兩者絕對值相同。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;     &lt;br /&gt;1. 製造測資時可考慮相離、相鄰、相交的情況，而相交的圖形可考慮「其中一圖有點在另一圖中」和「兩個圖形完全沒有點在另一個圖中，但有相交部份」的兩種情況。     &lt;br /&gt;2. 輸出時雖然每筆輸出之間不需換行，但最後結尾仍需要換行符號，否則會給WA，不是PE。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCES      &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.cnblogs.com/devymex/archive/2010/08/19/1803885.html"&gt;平面內兩條線段的位置關係判定及交點求解&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
using namespace std;

struct vertex{
  float x, y;
};

//return outer product of pa-&amp;gt;pb
float cross(vertex p, vertex a, vertex b){
  return ( (a.x - p.x)*(b.y - p.y) - (b.x - p.x)*(a.y - p.y) );
}

float dist(vertex a, vertex b){
  return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
}

//return true if p is inside or on boundary of g
bool inside(vertex p, vector&amp;lt;vertex&amp;gt; g, int n){
  int i = n - 1;
  for(; i&amp;gt;=0 &amp;amp;&amp;amp; (cross(g[i], g[(i+n-1)%n], p) &amp;gt;= 0); --i);
  return (i == -1);
}

bool intersects(vertex p1, vertex p2, vertex p3, vertex p4){
  return ((cross(p1, p2, p3) * cross(p1, p2, p4) &amp;lt; 0) &amp;amp;&amp;amp; (cross(p3, p4, p1) * cross(p3, p4, p2) &amp;lt; 0));
}

vertex intersection(vertex p1, vertex p2, vertex p3, vertex p4){
  float b1 = (p2.y - p1.y)*p1.x + (p1.x - p2.x)*p1.y;
  float b2 = (p4.y - p3.y)*p3.x + (p3.x - p4.x)*p3.y;
  float d = (p2.x - p1.x)*(p4.y - p3.y) - (p4.x - p3.x)*(p2.y - p1.y);
  float d1 = b2*(p2.x - p1.x) - b1*(p4.x - p3.x);
  float d2 = b2*(p2.y - p1.y) - b1*(p4.y - p3.y);
  vertex p0;
  p0.x = d1/d;
  p0.y = d2/d;
  return p0;
}

void check_intersect(vertex p1, vertex p2, vector&amp;lt;vertex&amp;gt; g, int n, vector&amp;lt;vertex&amp;gt; &amp;amp;gc){
  for(int i=0; i&amp;lt;n; ++i){
    if( intersects(p1, p2, g[i], g[(i+1)%n]) ){
      vertex inter = intersection(p1, p2, g[i], g[(i+1)%n]);
      gc.push_back(inter);
    }
  }
}

//check if ga vertices are inside gb
void check_vertices(vector&amp;lt;vertex&amp;gt; ga, int na, vector&amp;lt;vertex&amp;gt; gb, int nb, vector&amp;lt;vertex&amp;gt; &amp;amp;gc, bool calc_inter){
  for(int i=0; i&amp;lt;na; ++i){
    if( inside(ga[i], gb, nb) )
      gc.push_back(ga[i]);
    if( calc_inter )
      check_intersect(ga[i], ga[(i+1)%na], gb, nb, gc);
  }//i
}

void sort_vertices(vector&amp;lt;vertex&amp;gt; &amp;amp;g, int n){
  if( n &amp;gt; 0 ){
    int i, j, m = 0;
    for(i=1; i&amp;lt;n; ++i)
      if(g[i].y &amp;lt; g[m].y || (g[i].y == g[m].y &amp;amp;&amp;amp; g[i].x &amp;lt; g[m].y))
        m = i;
    swap(g[m], g[0]);
    for(i=1; i&amp;lt;n; ++i){
      m = i;
      for(j=i+1; j&amp;lt;n; ++j){
        float t = cross(g[0], g[m], g[j]);
        if( t &amp;lt; 0 || (t == 0 &amp;amp;&amp;amp; dist(g[0], g[j]) &amp;lt; dist(g[0], g[m])) )
          m = j;
      }//j
      swap(g[m], g[i]);
    }//i
  }
}

float area(vector&amp;lt;vertex&amp;gt; g, int n){
  float a = 0;
  for(int i=0; i&amp;lt;n; ++i)
    a += (g[(i+n-1)%n].x * g[i].y) - (g[i].x * g[(i+n-1)%n].y);
  return (a &amp;lt; 0) ? ( a / -2 ) : (a / 2);
}

int main(){
  int na, nb, nc; //number of vertices of graph a, b, c
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;na) &amp;amp;&amp;amp; (na != 0) ){
    vector&amp;lt;vertex&amp;gt; ga, gb, gc;
    vertex temp;
    
    for(int i=0; i&amp;lt;na; ++i){
      scanf(&amp;quot;%f%f&amp;quot;, &amp;amp;temp.x, &amp;amp;temp.y);
      ga.push_back(temp);
    }
    scanf(&amp;quot;%d&amp;quot;, &amp;amp;nb);
    for(int i=0; i&amp;lt;nb; ++i){
      scanf(&amp;quot;%f%f&amp;quot;, &amp;amp;temp.x, &amp;amp;temp.y);
      gb.push_back(temp);
    }
    
    check_vertices(ga, na, gb, nb, gc, 1);
    check_vertices(gb, nb, ga, na, gc, 0);
    nc = gc.size();
    sort_vertices(gc, nc);

    printf(&amp;quot;%8.2f&amp;quot;, area(ga, na) + area(gb, nb) - (2 * area(gc, nc)));
  }//while
  printf(&amp;quot;\n&amp;quot;);
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-635992791978169567?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/635992791978169567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-137-polygons.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/635992791978169567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/635992791978169567'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-137-polygons.html' title='ACM: 137 - Polygons'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_GF1-Pb0l-WE/TJNPi-jR79I/AAAAAAAAEl4/P00JPCtkEgo/s72-c/polygon-area.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6139074265119830782</id><published>2010-09-16T00:10:00.000+08:00</published><updated>2010-09-16T00:13:53.292+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 132 - Bumpy Objects</title><content type='html'>&lt;p&gt;Geometry的題目，給一個圖形的所有端點座標，和圖形的質心座標，要先找出可以讓圖形「站立」的邊，即當該邊水平時，質心在邊上方並在兩端點之間。一個圖形可能有大於一個可以站立的邊，邊的代號為該邊所經過最大編號(依輸入順序)的點，最後要輸出所有可以站立的邊中，最小的邊代號。&lt;/p&gt;  &lt;p&gt;我的做法分為兩部分，第一部分是找convex hull，用graham scan，找出圖形的凸包。第二部分用內積檢查凸包的每個邊是否可以讓圖形站立，即質心到邊兩端點的夾角是否都小於90度(內積&amp;gt;0)。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://online-judge.uva.es/board/viewtopic.php?f=1&amp;amp;t=4030&amp;amp;start=0&amp;amp;hilit=132&amp;amp;sid=21db04f6b5cb10a2545ac7c031d38a2c"&gt;UVa討論區&lt;/a&gt;有大量本題測資&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
using namespace std;

class vertex{
public:
  int x, y;
};

int n;
vertex mass;
vector&amp;lt;vertex&amp;gt; v; //original order
vector&amp;lt;int&amp;gt; p; //vertices id sorted by polar angle

//return outer product of pa-&amp;gt;pb
int cross(vertex p, vertex a, vertex b){
  return ( (a.x - p.x)*(b.y - p.y) - (b.x - p.x)*(a.y - p.y) );
}
//return true if pa dot pb &amp;gt; 0 (&amp;lt;90 degree)
bool dot(vertex p, vertex a, vertex b){
  return ( (a.x - p.x)*(b.x - p.x) + (a.y - p.y)*(b.y - p.y) ) &amp;gt; 0;
}

int dist(vertex a, vertex b){
  return ((b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y));
}
//return true if a should be placed first than b to form counter-clockwise order
bool issmaller(vertex p, vertex a, vertex b){
  int f = cross(p, a, b);
  return ( f &amp;lt; 0 || ( f == 0  &amp;amp;&amp;amp; dist(p, b) &amp;lt; dist(p, a) ) );
}

void quicksort(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    while(1){
      for(; (i&amp;lt;=right) &amp;amp;&amp;amp; issmaller(v[p[0]], v[p[left]], v[p[i]]); ++i);
      for(; (j&amp;gt;left) &amp;amp;&amp;amp; !issmaller(v[p[0]], v[p[left]], v[p[j]]); --j);
      if( i &amp;gt;= j )
        break;
      swap(p[i], p[j]);
    }
    swap(p[left], p[j]);
    quicksort(left, j-1);
    quicksort(j+1, right);
  }
}

int main(){
  string s;
  vertex temp;
  int i, j, tmp, minv, qn;
  
  while( (cin &amp;gt;&amp;gt; s) &amp;amp;&amp;amp; (s[0] != '#') ){
    scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;mass.x, &amp;amp;mass.y);
    v.clear();
    p.clear();
    i = 0;
    while( scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;temp.x, &amp;amp;temp.y) ){
      if( temp.x == 0 &amp;amp;&amp;amp; temp.y == 0 )
        break;
      v.push_back(temp);
      p.push_back(i++);
    }
    n = v.size();
    
    //find lowest-left
    for(minv=0, i=1; i&amp;lt;n; ++i)
      if( (v[i].y &amp;lt; v[minv].y) || (v[i].y == v[minv].y &amp;amp;&amp;amp; v[i].x &amp;lt; v[minv].x) )
        minv = i;
    swap(p[minv], p[0]);
    //sort all vertices counter clockwisely by polar angle
    quicksort(1, n - 1);
    
    //graham scan
    vector&amp;lt;int&amp;gt; q; //stack of convex hull
    q.push_back(p[0]);
    q.push_back(p[1]);
    for(i=2; i&amp;lt;n; ++i){
      qn = q.size() - 1;
      if( (tmp = cross( v[ q[qn-1] ], v[ q[qn] ], v[ p[i] ] )) &amp;gt; 0 )
        q.push_back(p[i]);
      else if( tmp == 0 ){
        q.pop_back();
        q.push_back(p[i]);
      }
      else{
        q.pop_back();
        --i;
      }
    }//i:all vertices
    q.push_back(p[0]);
    
    //find stable sides
    qn = q.size();
    for(minv=n-1, i=1; i&amp;lt;qn; ++i){
      if( (cross(v[q[i-1]], mass, v[q[i]])!=0) &amp;amp;&amp;amp; (dot(v[q[i-1]], mass, v[q[i]])&amp;gt;0) &amp;amp;&amp;amp; (dot(v[q[i]], mass, v[q[i-1]])&amp;gt;0) )
        if( (tmp = (q[i] &amp;gt; q[i-1]) ? q[i] : (n - 1)) &amp;lt; minv )
          minv = tmp;
    }

    cout &amp;lt;&amp;lt; s;
    for(i=s.size(); i&amp;lt;20; ++i)
      printf(&amp;quot; &amp;quot;);
    printf(&amp;quot;%d\n&amp;quot;, minv + 1);
  }//while
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6139074265119830782?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6139074265119830782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-132-bumpy-objects.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6139074265119830782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6139074265119830782'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-132-bumpy-objects.html' title='ACM: 132 - Bumpy Objects'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3401008692524016681</id><published>2010-09-14T14:37:00.001+08:00</published><updated>2010-09-14T14:37:25.820+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 131 - The Psychic Poker Player</title><content type='html'>&lt;p&gt;給玩家五張撲克牌，桌上有另五張的撲克牌，玩家可選擇捨棄0~5張牌，並從桌上依序補充同數量的牌。輸出可以達到的最大&lt;a href="http://www.pokersyte.com/basic.htm"&gt;牌型(poker hand)&lt;/a&gt;。&lt;/p&gt;  &lt;p&gt;用了bool陣列去窮舉所有捨棄牌的方式，遞補相同數量的牌後，再一一檢查牌型。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;

enum { C, D, H, S };
enum { SF, FOAK, FH, FL, ST, TOAK, TP, OP, HC };
bool result[9]={0,0,0,0,0,0,0,0,0};
char line[9][16] = {&amp;quot;straight-flush&amp;quot;, &amp;quot;four-of-a-kind&amp;quot;, &amp;quot;full-house&amp;quot;, 
&amp;quot;flush&amp;quot;, &amp;quot;straight&amp;quot;, &amp;quot;three-of-a-kind&amp;quot;, &amp;quot;two-pairs&amp;quot;, &amp;quot;one-pair&amp;quot;, &amp;quot;highest-card&amp;quot;};

class poker{
public:
  int denom;
  int suit;
};

int next(bool *slot);
void check(poker *c);

int main(){
  int i, j, k;
  poker cards[2][5];
  char s[10][3];
  
  i = j = k = 0;
  while( scanf(&amp;quot;%s&amp;quot;, s[k]) != EOF ){
    if( s[k][0]&amp;gt;='2' &amp;amp;&amp;amp; s[k][0]&amp;lt;='9' )
      cards[i][j].denom = s[k][0]-'0';
    else if( s[k][0] == 'A' )
      cards[i][j].denom = 1;
    else if( s[k][0] == 'T' )
      cards[i][j].denom = 10;
    else if( s[k][0] == 'J' )
      cards[i][j].denom = 11;
    else if( s[k][0] == 'Q' )
      cards[i][j].denom = 12;
    else if( s[k][0] == 'K' )
      cards[i][j].denom = 13;
    
    switch ( s[k][1] ){
      case 'C':
        cards[i][j].suit = C;
        break;
      case 'D':
        cards[i][j].suit = D;
        break;
      case 'H':
        cards[i][j].suit = H;
        break;
      case 'S':
        cards[i][j].suit = S;
        break;
    }//s[0]
    
    if( i==0 &amp;amp;&amp;amp; j==4 ){
      i = 1;
      j = 0;
    }
    else if( i==1 &amp;amp;&amp;amp; j==4 ){
      int count = 5;
      bool slot[5]={0, 0, 0, 0, 0};
      poker temp[5];
      while(1){
        j = 0;
        for(i=0; i&amp;lt;5; ++i){
          if( slot[i] )
            temp[i] = cards[1][j++];
          else
            temp[i] = cards[0][i];
        }
        check(temp);
        if( count == 0 )
          break;
        count = next(slot);
      }//search
      
      //output
      printf(&amp;quot;Hand: &amp;quot;);
      for(i=0; i&amp;lt;5; ++i)
        printf(&amp;quot;%s &amp;quot;, s[i]);
      printf(&amp;quot;Deck: &amp;quot;);
      for(; i&amp;lt;10; ++i)
        printf(&amp;quot;%s &amp;quot;, s[i]);
      printf(&amp;quot;Best hand: &amp;quot;);
      for(i=0; i&amp;lt;9 &amp;amp;&amp;amp; result[i]==0; ++i);
      printf(&amp;quot;%s\n&amp;quot;, line[i]);
      //initialize
      for(i=0; i&amp;lt;9; ++i)
        result[i] = 0;
      i = j = 0;
      k = -1;
    }
    else
      ++j;
    ++k;
  }//while get data
  
  return 0;
}

int next(bool *slot){
  if( slot[0] == 0 )
    slot[0] = 1;
  else{
    int i = 0;
    while( slot[i] == 1 )
      slot[i++] = 0;
    slot[i] = 1;
  }
  int count = 0;
  for(int i=0; i&amp;lt;5; ++i)
    if( slot[i] == 0 )
      ++count;
  return count;
}

void check(poker *c){
  int denoms[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  int suits[4]={0,0,0,0};
  
  //sort
  int i, j, min, maxsuit = 0;
  for(i=0; i&amp;lt;5; ++i){
    min = i;
    for(j=i+1; j&amp;lt;5; ++j)
      if( c[j].denom &amp;lt; c[min].denom )
        min = j;
    swap(c[i], c[min]);
    ++denoms[ c[i].denom ];
    if( ++suits[ c[i].suit ] &amp;gt; maxsuit )
      maxsuit = suits[ c[i].suit ];
  }
  
  //find if straight
  bool straight = 0;
  for(i=1; i&amp;lt;5 &amp;amp;&amp;amp; (c[i].denom == c[i-1].denom + 1); ++i);
  if( i == 5 )
    straight = 1;
  if(!straight &amp;amp;&amp;amp; (c[0].denom == 1)){
    for(i=2; i&amp;lt;5 &amp;amp;&amp;amp; (c[i].denom == c[i-1].denom + 1); ++i);
    if( i == 5 )
      straight = 1;
  }
  if( straight ){
    if( maxsuit == 5 )
      result[SF] = 1; //straight flush
    else
      result[ST] = 1; //straight
  }
  if( maxsuit == 5 )
    result[FL] = 1; //flush
  
  int three = 0, two = 0;
  for(i=1; i&amp;lt;=13; ++i){
    switch ( denoms[i] ){
      case 4:
        result[FOAK] = 1; //four of a kind
        break;
      case 3:
        result[TOAK] = 1; //three of a kind
        ++three;
        break;
      case 2:
        ++two;
    }
  }//i
  
  if( three == 1 &amp;amp;&amp;amp; two == 1 )
    result[FH] = 1; // full house
  else if( two == 2 )
    result[TP] = 1; //two pairs
  else if( two == 1 )
    result[OP] = 1; //one pair
  else
    result[HC] = 1; //highest card
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3401008692524016681?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3401008692524016681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-131-psychic-poker-player.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3401008692524016681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3401008692524016681'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-131-psychic-poker-player.html' title='ACM: 131 - The Psychic Poker Player'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6276570838157458212</id><published>2010-09-12T22:07:00.001+08:00</published><updated>2010-09-12T22:13:23.515+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Ubuntu!</title><content type='html'>&lt;p&gt;裝了&lt;a href="http://www.ubuntu.com/desktop/get-ubuntu/windows-installer"&gt;Wubi&lt;/a&gt;，直接從Windows像安裝應用程式一樣安裝了&lt;a href="http://www.ubuntu.com/"&gt;Ubuntu&lt;/a&gt;！不需要分割硬碟，也不需設定虛擬機器。裝的是Ubuntu 10.x，好漂亮，語言支援也很方便，雖然安裝的是英文版，但顯示中文完全沒問題，中文輸入也可以很方便的直接從System-&amp;gt;Preference-&amp;gt;iBus打開！&lt;/p&gt;  &lt;p&gt;不過還要慢慢摸索linux，還是裝個Virtual Box同時用Windows跟Ubuntu吧。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6276570838157458212?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6276570838157458212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6276570838157458212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6276570838157458212'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/ubuntu.html' title='Ubuntu!'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8157303947646149815</id><published>2010-09-11T22:40:00.000+08:00</published><updated>2010-09-11T22:42:16.813+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>Rails 3.0初體驗</title><content type='html'>&lt;p&gt;終於成功嘗試Ruby on Rails了。安裝的是rails 3.0.0，一些以舊版rails為基礎的教學文件語法不同，後來找到了rails 3版本的教學文件&amp;quot;&lt;a href="http://edgeguides.rubyonrails.org/getting_started.html"&gt;Getting Started with Rails&lt;/a&gt;&amp;quot;，終於step by step照著敲出了個最基礎的blog平台，有blog文章增刪修、comment增刪、tag，三項功能。&lt;/p&gt;  &lt;p&gt;資料庫使用的是預設的SQLite，先照著&lt;a href="http://philip.pixnet.net/blog/post/27040305"&gt;查到的資料&lt;/a&gt;排除找不到&amp;quot;sqlite3.dll&amp;quot;的錯誤訊息。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8157303947646149815?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8157303947646149815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/rails-30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8157303947646149815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8157303947646149815'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/rails-30.html' title='Rails 3.0初體驗'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5009824219343121609</id><published>2010-09-10T21:16:00.000+08:00</published><updated>2010-09-10T21:17:09.622+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM 30 題</title><content type='html'>&lt;p&gt;不知不覺把121 - 130寫完了，這10題練習了C++的vector、string和其提供的函式。題目本身的話，印象最深的是DP的&amp;quot;125 – Numbering Paths&amp;quot;和學到運用餘數的&amp;quot;128 – Software CRC&amp;quot;。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5009824219343121609?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5009824219343121609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5009824219343121609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5009824219343121609'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-30.html' title='ACM 30 題'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-2699315730964110240</id><published>2010-09-10T20:53:00.001+08:00</published><updated>2010-09-10T20:53:35.294+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 130 – Roman Roulette</title><content type='html'>&lt;p&gt;simulation，但規則有點看不懂，看了&lt;a href="http://shik.pixnet.net/blog/post/16748563"&gt;中譯&lt;/a&gt;才搞清楚...&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
using namespace std;

int n, k;
int kill(int i, vector&amp;lt;int&amp;gt; v);

int main(){
  int i, t;
  vector&amp;lt;int&amp;gt; r;
  
  while( (cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; k) &amp;amp;&amp;amp; (n != 0) ){
    r.clear();
    for(i=1; i&amp;lt;=n; ++i)
      r.push_back(i);
    
    t = kill(0, r) - 1;
    t = (n - t) % n;
    cout &amp;lt;&amp;lt; t + 1 &amp;lt;&amp;lt; endl;
  }//while
  return 0;
}

int kill(int i, vector&amp;lt;int&amp;gt; v){
  int p;
  --i;
  while( v.size() &amp;gt; 1 ){
    i = p = (i+k) % v.size(); //p: killed
    v.erase(v.begin()+i);
    i = (i+k-1) % v.size(); //i: burier
    v.insert(v.begin()+p, v[i]);
    if( i &amp;gt;= p )
      ++i;
    v.erase(v.begin()+i);
    if( i &amp;gt;= p )
      i = p % v.size();
    else
      i = (p - 1) % v.size();
  }
  return v[0];
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-2699315730964110240?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/2699315730964110240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-130-roman-roulette.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2699315730964110240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2699315730964110240'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-130-roman-roulette.html' title='ACM: 130 – Roman Roulette'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6782582887389417613</id><published>2010-09-10T20:41:00.001+08:00</published><updated>2010-09-10T20:41:18.215+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 129 – Krypton Factor</title><content type='html'>&lt;p&gt;生成所有排序(permutations)，但要檢查生成的permutation是否有連續的重複組合，如有連續的重複組合即為無效的permutatoin，若否則為有效的permutation。如&amp;quot;&lt;u&gt;ABAB&lt;/u&gt;&amp;quot;為無效，因連續出現&amp;quot;AB&amp;quot;組合，但&amp;quot;&lt;u&gt;AB&lt;/u&gt;C&lt;u&gt;AB&lt;/u&gt;&amp;quot;則為有效。輸出指定的第n個有效permutation。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

#define MAX 80
int n, let, seqn;
bool check(char *s, int len);
void gen(char *s, int len);
void output(char *s, int len);

int main(){
  char s[MAX];
  while( (cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; let) &amp;amp;&amp;amp; (n != 0) ){
    seqn = 0;
    gen(s, 0);
  }//while
  return 0;
}

//return true if string is &amp;quot;hard&amp;quot;, false when &amp;quot;easy&amp;quot;
bool check(char *s, int len){
  int i, j, k;
  for(i=0; i&amp;lt;len; ++i){
    for(j=0; j&amp;lt;i; ++j){
      for(k=j; k&amp;lt;i &amp;amp;&amp;amp; s[k]==s[i+k-j]; ++k) ;//k
      if( k == i )
        return false;
    }//j
  }//i
  return true;
}

void gen(char *s, int len){
  for(int i=0; i&amp;lt;let &amp;amp;&amp;amp; seqn&amp;lt;n; ++i){
    s[len] = 'A' + i;
    s[len+1] = '\0';
    if( check(s, len+1) ){
      if( ++seqn == n ){
        output(s, len+1);
        return;
      }
      if( seqn &amp;lt; n )
        gen(s, len+1);
    }
  }//i
}

void output(char *s, int len){
  for(int i=0; i&amp;lt;len; ++i){
    if( i == 64 )
      cout &amp;lt;&amp;lt; endl;
    else if( i&amp;gt;0 &amp;amp;&amp;amp; i%4==0 )
      cout &amp;lt;&amp;lt; ' ';
    cout &amp;lt;&amp;lt; s[i];
  }//i
  cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; len &amp;lt;&amp;lt; endl;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6782582887389417613?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6782582887389417613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-129-krypton-factor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6782582887389417613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6782582887389417613'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-129-krypton-factor.html' title='ACM: 129 – Krypton Factor'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7846560886661038340</id><published>2010-09-09T20:50:00.001+08:00</published><updated>2010-09-09T20:50:13.293+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 127 - "Accordian" Patience</title><content type='html'>&lt;p&gt;simulation。給52張撲克牌，向左一張或左三張合併同數字或同花色，輸出合併完成後剩下的堆數和每一堆的張數。每合併一次，要檢查是否可以繼續再向左合併。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

#define MAX 52

int main(){
  int i, j, k, moveto;
  char pile[MAX][MAX+MAX], remain[MAX];
  int len[MAX];
  
  while( (cin &amp;gt;&amp;gt; pile[0]) &amp;amp;&amp;amp; (pile[0][0] != '#') ){
    len[0] = 2;
    for(i=1; i&amp;lt;MAX; i++){
      cin &amp;gt;&amp;gt; pile[i];
      len[i] = 2;
    }//i: read in all cards
    
    i=1;
    while( i &amp;lt; MAX ){
      moveto = i;
      for(j=i-1; j&amp;gt;=0 &amp;amp;&amp;amp; len[j]==0; --j);//1 left
      if( (j &amp;gt;= 0) &amp;amp;&amp;amp; (pile[j][ len[j]-2 ] == pile[i][ len[i]-2 ] || pile[j][ len[j]-1 ] == pile[i][ len[i]-1 ]) )
        moveto = j;
      for(--j; j&amp;gt;=0 &amp;amp;&amp;amp; len[j]==0; --j);//2 left
      for(--j; j&amp;gt;=0 &amp;amp;&amp;amp; len[j]==0; --j);//3 left
      if( (j &amp;gt;= 0) &amp;amp;&amp;amp; (pile[j][ len[j]-2 ] == pile[i][ len[i]-2 ] || pile[j][ len[j]-1 ] == pile[i][ len[i]-1 ]) )
        moveto = j;
      if( i != moveto ){
        len[i] -= 2;
        pile[moveto][ len[moveto]++ ] = pile[i][ len[i] ];
        pile[moveto][ len[moveto]++ ] = pile[i][ len[i]+1 ];
        i = moveto;
      }
      else
        for(++i; i&amp;lt;MAX &amp;amp;&amp;amp; len[i]==0; ++i);
    }
    
    k = 0;
    for(i=0; i&amp;lt;MAX; i++)
      if( len[i] &amp;gt; 0 )
        remain[k++] = i;
    cout &amp;lt;&amp;lt; k &amp;lt;&amp;lt; ( k == 1 ? &amp;quot; pile&amp;quot; : &amp;quot; piles&amp;quot; ) &amp;lt;&amp;lt; &amp;quot; remaining:&amp;quot;;
    for(i=0; i&amp;lt;k; i++)
      cout &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; (len[ remain[i] ] / 2);
    cout &amp;lt;&amp;lt; endl;
  }//while
  
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7846560886661038340?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7846560886661038340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-127-patience.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7846560886661038340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7846560886661038340'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-127-patience.html' title='ACM: 127 - &amp;quot;Accordian&amp;quot; Patience'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5510537952053086956</id><published>2010-09-09T04:37:00.001+08:00</published><updated>2010-09-09T04:37:06.538+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 126 - The Errant Physicist</title><content type='html'>&lt;p&gt;給多項式，輸出x降冪y升冪排序後的多項式相乘結果。重點在於字串處理，要找到方法把輸入字串拆解出可以運算的係數及次方數。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;記得移除(不要輸出)合併同類項後係數為0的項&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;sstream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;cstring&amp;gt;
using namespace std;

class term{
public:
  int coef; //coefficient
  int pow_x;
  int pow_y;
};

vector&amp;lt;term&amp;gt; poly[2], result;

void get_terms(int no, string s);
void multiply(term a, term b);
void sort_terms(int left, int right);
void comb_terms(void);
bool isbigger(int a, int b);
string atostring(int num);

int main(){
  int i, j, n;
  string s, line1, line2;
  
  while( cin &amp;gt;&amp;gt; s ){
    if( s[0] == '#' )
      break;
    
    get_terms(0, s);
    cin &amp;gt;&amp;gt; s;
    get_terms(1, s);
    
    result.clear();
    for(i=0; i&amp;lt;poly[1].size(); i++)
      for(j=0; j&amp;lt;poly[0].size(); j++)
        multiply(poly[1][i], poly[0][j]);
    
    sort_terms(0, result.size()-1); //sort
    comb_terms(); //combine like terms
    
    line1.clear();
    line2.clear();
    for(i=0; i&amp;lt;result.size(); i++){
      //sign
      if( i &amp;gt; 0 ){
        line1.append(&amp;quot;   &amp;quot;);
        if( result[i].coef &amp;gt; 0 )
          line2.append(&amp;quot; + &amp;quot;);
        else
          line2.append(&amp;quot; - &amp;quot;);
      }
      //coefficient
      if( result[i].coef &amp;lt; 0 ){
        result[i].coef *= -1;
        if( i==0 ){
          line1.push_back(' ');
          line2.push_back('-');
        }
      }
      if( result[i].coef &amp;gt; 1 ){
        s = atostring(result[i].coef);
        line2.append(s);
        n = s.size();
        for(j=0; j&amp;lt;n; j++)
          line1.push_back(' ');
      }
      else if( result[i].coef == 1 &amp;amp;&amp;amp; result[i].pow_x == 0 &amp;amp;&amp;amp; result[i].pow_y == 0 ){
        line1.push_back(' ');
        line2.push_back('1');
      }
      //power of x
      if( result[i].pow_x &amp;gt;= 1 ){
        line1.push_back(' ');
        line2.push_back('x');
      }
      if( result[i].pow_x &amp;gt; 1 ){
        s = atostring(result[i].pow_x);
        line1.append(s);
        n = s.size();
        for(j=0; j&amp;lt;n; j++)
          line2.push_back(' ');
      }
      //power of y
      if( result[i].pow_y &amp;gt;= 1 ){
        line1.push_back(' ');
        line2.push_back('y');
      }
      if( result[i].pow_y &amp;gt; 1 ){
        s = atostring(result[i].pow_y);
        line1.append(s);
        n = s.size();
        for(j=0; j&amp;lt;n; j++)
          line2.push_back(' ');
      }
    }//i
    cout &amp;lt;&amp;lt; line1 &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; line2 &amp;lt;&amp;lt; endl;
  }//while
  
  return 0;
}

void get_terms(int no, string s){
  poly[no].clear(); //initialize polynomial vector
  
  term temp;
  string number;
  int sign = 1;
  int size = s.size();
  char flag = '+';
  
  for(int i=0; i&amp;lt;=size; i++){
    if( i==0 || i == size || s[i] == '+' || s[i] == '-' ){
      //if end of term
      if( i &amp;gt; 0 ){
        if( flag == '+' || flag == '-' )
          temp.coef = atoi(number.c_str()) * sign;
        else if( flag == 'x' ){
          if( s[i-1] == 'x' )
            temp.pow_x = 1;
          else
            temp.pow_x = atoi(number.c_str());
        }
        else if( flag == 'y' ){
          if( s[i-1] == 'y' )
            temp.pow_y = 1;
          else
            temp.pow_y = atoi(number.c_str());
        }
        poly[no].push_back(temp);
      }
      //initialize term
      temp.coef = temp.pow_x = temp.pow_y = 0;
      sign = 1;
      flag = '+';
      number.clear();
      //new term
      if( i &amp;lt; size &amp;amp;&amp;amp; s[i] == '-' ){
        sign = -1;
        flag = '-';
      }
    }//term break point
    
    if( s[i] == 'x' || s[i] == 'y' ){
      if( i == 0 )
        temp.coef = sign;
      else if( flag == '+' || flag == '-' ){
        if( s[i-1] == flag )
          temp.coef = sign;
        else
          temp.coef = atoi(number.c_str()) * sign;
      }
      else if( flag == 'x' ){
        if( s[i-1] == 'x' )
          temp.pow_x = 1;
        else
          temp.pow_x = atoi(number.c_str());
      }
      else if( flag == 'y' ){
        if( s[i-1] == 'y' )
          temp.pow_y = 1;
        else
          temp.pow_y = atoi(number.c_str());
      }
      flag = s[i];
      number.clear();
    }
    else if( s[i] &amp;gt;= '0' &amp;amp;&amp;amp; s[i] &amp;lt;= '9' )
      number.push_back(s[i]);
  }//i
}

void multiply(term a, term b){
  term temp;
  temp.coef = a.coef * b.coef;
  temp.pow_x = a.pow_x + b.pow_x;
  temp.pow_y = a.pow_y + b.pow_y;
  result.push_back(temp);
}

void sort_terms(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    while(1){
      for(; i&amp;lt;=right &amp;amp;&amp;amp; !isbigger(i, left); i++);
      for(; j&amp;gt;left &amp;amp;&amp;amp; isbigger(j, left); j--);
      if( i &amp;gt;= j )
        break;
      swap(result[i], result[j]);
    }//while
    swap(result[j], result[left]);
    sort_terms(left, j-1);
    sort_terms(j+1, right);
  }
}

//return true when a&amp;gt;b, false when a&amp;lt;=b
bool isbigger(int a, int b){
  if( result[a].pow_x &amp;lt; result[b].pow_x )
    return true;
  if( result[a].pow_x &amp;gt; result[b].pow_x )
    return false;
  if( result[a].pow_y &amp;gt; result[b].pow_y )
    return true;
  return false;
}

void comb_terms(void){
  int i = 0;
  while( i &amp;lt; result.size() ){
    if( result[i].coef == 0 )
      result.erase(result.begin()+i);
    else if( i &amp;lt; (result.size()-1) &amp;amp;&amp;amp; (result[i].pow_x == result[i+1].pow_x) &amp;amp;&amp;amp; (result[i].pow_y == result[i+1].pow_y) ){
      result[i].coef += result[i+1].coef;
      result.erase(result.begin()+i+1);
    }
    else
      i++;
  }
}

string atostring(int num){
  stringstream ss;
  ss &amp;lt;&amp;lt; num;
  return ss.str();
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5510537952053086956?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5510537952053086956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-126-errant-physicist.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5510537952053086956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5510537952053086956'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-126-errant-physicist.html' title='ACM: 126 - The Errant Physicist'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7902251712339619021</id><published>2010-09-07T05:07:00.000+08:00</published><updated>2010-09-07T05:07:21.857+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 125 – Numbering Paths</title><content type='html'>&lt;p&gt;這題頗有挑戰性，給有向圖(directed graph)，要找出圖上是否有環(cycle)，也要找出所有點之間存在的所有路徑數量，當路徑經過環(即代表路徑數量無窮大)，路徑數量要輸出-1。&lt;/p&gt;  &lt;p&gt;我的作法是先以dp(Floyd-Warshall做變化)找出所有點之間存在的所有路徑數量，接著判斷是否有k-&amp;gt;k (k = 1….n)路徑存在，若存在即為環存在，再跑一次迴圈將所有可與k相連的路徑的值設為-1。&lt;/p&gt;  &lt;p&gt;在寫的時候原本Floyd-Warshall的觀念還是沒想清楚，在最外面多加了一層算「經過幾個點」的迴圈，寫出來超冗長且bug連連。後來改用recursive去產出所有組合，想當然Time Limit Exceed。苦思良久才領悟到不必多加那一層迴圈，也搞清楚找到環以後如何去刪掉所有受影響的節點了。柳暗花明，最後看到了清爽的程式碼 :))&lt;/p&gt;  &lt;p&gt;不過仍然是跑了兩次三層迴圈，應該算O(2 * n^3)吧，一定可以更省，就繼續研究吧。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

#define MAX 30

int main(){
  int i, j, k;
  int maxn, side, d1, d2, total;
  int matrix[MAX][MAX]; //total number of paths
  
  total = 0;
  while( cin &amp;gt;&amp;gt; side ){
    for(i=0; i&amp;lt;MAX; i++)
      for(j=0; j&amp;lt;MAX; j++)
        matrix[i][j] = 0;
        
    maxn = -1;
    for(i=0; i&amp;lt;side; i++){
      cin &amp;gt;&amp;gt; d1 &amp;gt;&amp;gt; d2;
      matrix[d1][d2] = 1;
      if( d1 &amp;gt; maxn ) maxn = d1;
      if( d2 &amp;gt; maxn ) maxn = d2;
    }
    maxn++;
  
    //findout all paths
    for(k=0; k&amp;lt;maxn; k++)
      for(i=0; i&amp;lt;maxn; i++)
        for(j=0; j&amp;lt;maxn; j++)
          if( matrix[i][k] * matrix[k][j] &amp;gt; 0 )
            matrix[i][j] += matrix[i][k];
    
    //eliminate paths involved cycles
    for(k=0; k&amp;lt;maxn; k++)
      if( matrix[k][k] != 0 ) //cycle
        for(i=0; i&amp;lt;maxn; i++)
          for(j=0; j&amp;lt;maxn; j++)
            if( matrix[i][k] * matrix[k][j] != 0 )
              matrix[i][j] = -1;
    
    //output
    cout &amp;lt;&amp;lt; &amp;quot;matrix for city &amp;quot; &amp;lt;&amp;lt; total &amp;lt;&amp;lt; endl;
    for(i=0; i&amp;lt;maxn; i++){
      cout &amp;lt;&amp;lt; matrix[i][0];
      for(j=1; j&amp;lt;maxn; j++)
        cout &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; matrix[i][j];
      cout &amp;lt;&amp;lt; endl;
    }
    
    total++;
  }//while
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7902251712339619021?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7902251712339619021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-125-numbering-paths.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7902251712339619021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7902251712339619021'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-125-numbering-paths.html' title='ACM: 125 – Numbering Paths'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1823692776222900721</id><published>2010-09-06T02:55:00.000+08:00</published><updated>2010-09-06T02:57:08.354+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 124 – Following Orders</title><content type='html'>&lt;p&gt;真開心再用vector寫出了這題，嘗試用vector的push_back()及erase()產生所有的組合。在取出元素時檢查未被取出的元素是否有小於該元素的元素(小的元素應該先被取出)。&lt;/p&gt;  &lt;p&gt;這題是給一些元素，再給其中部分元素的大小關係，依字典順序輸出在給定的大小關係下所有可能的元素組合。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;

#define MAX_LET 26

vector&amp;lt;char&amp;gt; vars; //variables
bool consts[MAX_LET][MAX_LET]; //constraints

void sort_vars(int left, int right);
void comb(vector&amp;lt;char&amp;gt; current, vector&amp;lt;char&amp;gt; pool);

int main(){
  int i, j;
  char c, d1, d2;
  bool flag = false;
  
  for(i=0; i&amp;lt;MAX_LET; i++)
    for(j=0; j&amp;lt;MAX_LET; j++)
      consts[i][j] = false;
  
  while( (c = getchar()) != EOF ){
    if( c &amp;gt;= 'a' &amp;amp;&amp;amp; c &amp;lt;= 'z' ){
      vars.push_back(c);
    }//get variables
    else if( c == '\n' ){
      while( (d1 = getchar()) != '\n' ){
        if( d1 &amp;gt;= 'a' &amp;amp;&amp;amp; d1 &amp;lt;= 'z' ){
          cin &amp;gt;&amp;gt; d2;
          consts[d2-'a'][d1-'a'] = true;
        }
      }//while get constraints
      
      if(flag == true)
        puts(&amp;quot;&amp;quot;);
      sort_vars(0, vars.size()-1); //sort variables
      vector&amp;lt;char&amp;gt; tmp;
      comb(tmp, vars); //produce combinations
      
      //initialize
      flag = true;
      vars.clear();
      for(i=0; i&amp;lt;MAX_LET; i++)
        for(j=0; j&amp;lt;MAX_LET; j++)
          consts[i][j] = false;
    }//get constraints
  }  
  
  return 0;
}

void sort_vars(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    
    while(1){
      for(; (i&amp;lt;=right) &amp;amp;&amp;amp; (vars[i] &amp;lt;= vars[left]); i++);
      for(; (j&amp;gt;left) &amp;amp;&amp;amp; (vars[j] &amp;gt; vars[left]); j--);
      if( i&amp;gt;=j )
        break;
      swap(vars[i], vars[j]);
    }
    swap(vars[j], vars[left]);
    sort_vars(left, j-1);
    sort_vars(j+1, right);
  }
}

void comb(vector&amp;lt;char&amp;gt; current, vector&amp;lt;char&amp;gt; pool){
  vector&amp;lt;char&amp;gt;::size_type i, j;
  if( pool.empty() ){
    for(i=0; i!=current.size(); i++)
      cout &amp;lt;&amp;lt; current[i];
    cout &amp;lt;&amp;lt; endl;
    return;
  }
  
  vector&amp;lt;char&amp;gt; tmp_cur, tmp_pool;
  vector&amp;lt;char&amp;gt;::size_type psize = pool.size();
  for(i=0; i&amp;lt;psize; i++){
    for(j=0; j&amp;lt;psize; j++){
      if( consts[ pool[i]-'a' ][ pool[j]-'a' ] )
        break;
    }
    if( j == psize ){
      tmp_pool = pool;
      tmp_cur = current;
      tmp_cur.push_back(pool[i]);
      tmp_pool.erase(tmp_pool.begin()+i);
    
      comb(tmp_cur, tmp_pool);
    }
  }//i
  return;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1823692776222900721?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1823692776222900721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-124-following-order.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1823692776222900721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1823692776222900721'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-124-following-order.html' title='ACM: 124 – Following Orders'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6192815164062756560</id><published>2010-09-05T23:30:00.000+08:00</published><updated>2010-09-05T23:31:07.196+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 123 – Searching Quickly</title><content type='html'>&lt;p&gt;這題是要在所給的一連串字串中，排除特定一些關鍵字，再將排除後剩餘的所有單字連同原字串順序輸出。&lt;/p&gt;  &lt;p&gt;寫出來相當開心！第一次嘗試使用C++的class與string, vector等STL(Standard Template Library)，也使用了自訂class來做vector！string和vector乍看之下有點抽象，但實作起來還蠻方便有趣的，C++ Primer的作者在書中不斷警告使用者在C++要減少使用char*和array。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;

class cls_kwords{
public:
  string keyword;
  int title_no;
  int position; //ending position of keyword in title
};

const int to_low = 'a' - 'A';
vector&amp;lt;string&amp;gt; words; //vector of words to ignore
vector&amp;lt;string&amp;gt; titles;
vector&amp;lt;cls_kwords&amp;gt; keywords;

void sort_words(int left, int right);
void sort_keywords(int left, int right);
bool isignore(string line);
bool isbigger(int a, int b);

int main(){
  string s;
  
  while( cin &amp;gt;&amp;gt; s ){
    if( s[0] == ':' ) break;
    words.push_back(s);
  }//words to ignore
  
  //sort words to ignore
  sort_words(0, words.size()-1);
  
  //get titles
  int total = 0;
  string key;
  string::size_type i, len;
  cls_kwords tmp;
  
  while( getline(cin, s) ){
    if( !s.empty() ){
      len = s.size();
      for(i=0; i&amp;lt;=len; i++){
        if( i == len || s[i] == ' ' ){
          if( !key.empty() ){
            if( !isignore(key) ){
              tmp.keyword = key;
              tmp.title_no = total;
              tmp.position = i;
              keywords.push_back(tmp);
            }
            key = &amp;quot;&amp;quot;;
          }
        }
        else if( s[i] &amp;gt;= 'A' &amp;amp;&amp;amp; s[i] &amp;lt;= 'Z' ){
          s[i] += to_low;
          key += s[i];
        }
        else if( s[i] &amp;gt;= 'a' &amp;amp;&amp;amp; s[i] &amp;lt;= 'z' )
          key += s[i];
      }//i

      titles.push_back(s);
      total++;
    }
  }//while get titles
  
  int ksize, st, j;
  //sort keywords
  ksize = keywords.size();
  sort_keywords(0, ksize-1);
  
  //output
  for(int k=0; k!=ksize; k++){
    len = titles[ keywords[k].title_no ].size();
    st = keywords[k].position - keywords[k].keyword.size();
    for(j=0; j&amp;lt;st; j++)
      cout &amp;lt;&amp;lt; titles[ keywords[k].title_no ][j];
    for(; j&amp;lt;keywords[k].position; j++)
      printf(&amp;quot;%c&amp;quot;, titles[ keywords[k].title_no ][j] - to_low);
    for(; j&amp;lt;len; j++)
      cout &amp;lt;&amp;lt; titles[ keywords[k].title_no ][j];
    cout &amp;lt;&amp;lt; endl;
  }
  
  return 0;
}

void sort_words(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    
    while(1){
      for(; (i&amp;lt;=right) &amp;amp;&amp;amp; (words[i]&amp;lt;=words[left]); i++);
      for(; (j&amp;gt;left) &amp;amp;&amp;amp; (words[j]&amp;gt;words[left]); j--);
      if( i &amp;gt;= j )
        break;
      swap(words[i++], words[j--]);
    }//while
    swap(words[j], words[left]);
    sort_words(left, j-1);
    sort_words(j+1, right);
  }
}

bool isignore(string line){
  vector&amp;lt;string&amp;gt;::size_type i, max = words.size();

  for(i=0; i&amp;lt;max; i++){
    if( line &amp;lt; words[i] ) break;
    else if( line == words[i] ) return true;
  }

  return false;
}

void sort_keywords(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    
    while(1){
      for(; (i&amp;lt;=right) &amp;amp;&amp;amp; (!isbigger(i, left)) ; i++);
      for(; (j&amp;gt;left) &amp;amp;&amp;amp; (isbigger(j, left)) ; j--);
      if( i &amp;gt;= j )
        break;
      swap(keywords[i++], keywords[j--]);
    }
    swap(keywords[j], keywords[left]);
    sort_keywords(left, j-1);
    sort_keywords(j+1, right);
  }
}

//return true when a&amp;gt;b, false when a&amp;lt;=b
bool isbigger(int a, int b){
  if( a == b ) return false;
  
  if( keywords[a].keyword &amp;gt; keywords[b].keyword ) return true;
  else if( keywords[a].keyword &amp;lt; keywords[b].keyword ) return false;
  
  if( keywords[a].title_no &amp;gt; keywords[b].title_no ) return true;
  else if( keywords[a].title_no &amp;lt; keywords[b].title_no ) return false;
  
  if( keywords[a].position &amp;gt; keywords[b].position ) return true;
  else if( keywords[a].position &amp;lt; keywords[b].position ) return false;
  
  return false;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6192815164062756560?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6192815164062756560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-123-searching-quickly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6192815164062756560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6192815164062756560'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-123-searching-quickly.html' title='ACM: 123 – Searching Quickly'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6242000904506285339</id><published>2010-09-04T23:51:00.001+08:00</published><updated>2010-09-04T23:51:16.036+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 122 – Trees on the level</title><content type='html'>&lt;p&gt;這題是用文字給出二元樹，檢查是否是完整的樹，如果是完整的樹即輸出廣度優先搜尋(BFS, Bread First Search)的結果。&lt;/p&gt;  &lt;p&gt;我用的方法是用quicksort先對字串排序(eg, L, R, LL, LR, RL, RR,…)，接著檢查是否是完整的樹，最後再照字串順序輸出該node的數字。Runtime 0.008，程式碼也相當龐大，在這題來說顯然有更快更精簡的方法，也許可以考慮使用struct, C++的STL函式庫，也許會有更好的表現。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;

#define MAX_LEN 300
#define MAX_NODE 256

int total, num[MAX_NODE], len[MAX_NODE];
char line[MAX_NODE][MAX_NODE];
bool rep;

void sort_tree(int left, int right);
bool isbigger(int a, int b);
void swapnode(int a, int b);
bool valid_tree(void);

int main(){
  char c, snum[MAX_LEN], sline[MAX_LEN];
  int p, pnum, pline;
  int i;
  
  rep = false;
  total = 0;
  for(i=0; i&amp;lt;MAX_NODE; i++)
    num[i] = -1;
    
  while( (c = getchar()) != EOF ){
    if( c == '(' ){
      p = pnum = pline = 0;
    }
    else if( c == ')' ){
      if( p == 0 ){        
        sort_tree(0, total-1);
        
        if( valid_tree() ){
          cout &amp;lt;&amp;lt; num[0];
          for(i=1; i&amp;lt;total; i++)
            cout &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; num[i];
          cout &amp;lt;&amp;lt; endl;
        }
        else
          cout &amp;lt;&amp;lt; &amp;quot;not complete&amp;quot; &amp;lt;&amp;lt; endl;
        //initialize
        rep = false;
        total = 0;
        for(i=0; i&amp;lt;MAX_NODE; i++)
          num[i] = -1;
      }//end of tree
      else{
        if( pnum &amp;gt; 0 ){
          snum[pnum] = '\0';
          sscanf(snum, &amp;quot;%d&amp;quot;, &amp;amp;num[total]);
          
          for(i=0; i&amp;lt;pline; i++)
            line[total][i] = sline[i];
          line[total][pline] = '\0';
          len[total] = pline;
        }//if pnum &amp;gt; 0
        total++;
      }//end of node
    }
    else if( c == ',' ){
      p++;
    }
    else if( c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9' ){
      snum[pnum++] = c;
      p++;
    }
    else if( c == 'L' || c == 'R' ){
      sline[pline++] = c;
      p++;
    }
    else ;
  }//while
  
  return 0;
}

void sort_tree(int left, int right){
  if( left &amp;lt; right ){
    int i = left + 1;
    int j = right;
    
    while(1){
      for(i; (isbigger(i, left)==false) &amp;amp;&amp;amp; (i&amp;lt;=right); i++);
      for(j; (isbigger(j, left)==true) &amp;amp;&amp;amp; (j&amp;gt;left); j--);
      if( i &amp;gt;= j )
        break;
      swapnode(i, j);
      i++;
      j--;
    }//while
    
    swapnode(left, j);
    sort_tree(left, j-1);
    sort_tree(j+1, right);
  }
}

//return true if a &amp;gt; b, return false if a &amp;lt;= b
bool isbigger(int a, int b){
  if( a == b )
    return false;
  if( len[a] &amp;gt; len[b] )
    return true;
  if( len[a] &amp;lt; len[b] )
    return false;
  
  for(int i=0; i&amp;lt;len[a]; i++){
    if( line[a][i] &amp;gt; line[b][i] )
      return true;
    else if( line[a][i] &amp;lt; line[b][i] )
      return false;
  }
  
  rep = true;
  return false;
}

void swapnode(int a, int b){
  swap(num[a], num[b]);
  swap(len[a], len[b]);
  
  char tmps[MAX_LEN];
  strcpy(tmps, line[a]);
  strcpy(line[a], line[b]);
  strcpy(line[b], tmps);
}

bool valid_tree(void){  
  if( (num[0] == -1) || (len[0] != 0) )
    return false;
  if( rep )
    return false;
  
  int i, j;
  bool flag;
  char tmps[MAX_LEN];
  for(i=1; len[i]&amp;lt;=1 &amp;amp;&amp;amp; i&amp;lt;total; i++)
    if( num[i] == -1 )
      return false;
  for(i; i&amp;lt;total; i++){
    if( num[i] == -1 )
      return false;
      
    flag = false;
    for(j=0; j&amp;lt;(len[i]-1); j++)
      tmps[j] = line[i][j];
    tmps[j] = '\0';
    for(j=(i-1); (j&amp;gt;=0) &amp;amp;&amp;amp; (len[j]&amp;gt;=(len[i]-1)); j--)
      if( strcmp(line[j], tmps) == 0 ){
        flag = true;
        break;
      }

    if( !flag )
      return false;
  }//i
  
  return true;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6242000904506285339?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6242000904506285339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-122-trees-on-level.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6242000904506285339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6242000904506285339'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/acm-122-trees-on-level.html' title='ACM: 122 – Trees on the level'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-9199930733660605840</id><published>2010-09-03T18:31:00.000+08:00</published><updated>2010-09-03T18:32:02.559+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>《約耳談軟體》</title><content type='html'>&lt;p&gt;把線上版的&lt;a href="http://local.joelonsoftware.com/wiki/%E9%A6%96%E9%A0%81" target="_blank"&gt;《約耳談軟體》(Joel On Software)&lt;/a&gt;照著&lt;a href="http://local.joelonsoftware.com/wiki/The_Joel_on_Software_Translation_Project:%E5%AF%A6%E9%AB%94%E6%9B%B8" target="_blank"&gt;實體書出版目錄&lt;/a&gt;至少看過了一遍，是融合技術、經驗、娛樂、還有勵志性的好看的書！書內談許多軟體專案開發的實務技巧，強調寫規格、定時程、Daily Build的重要性，也談及專案管理及軟體商業策略等等。&lt;/p&gt;  &lt;p&gt;雖然有些內容還無法完全了解，但似乎對軟體業多了一分認識，也從&lt;a href="http://local.joelonsoftware.com/wiki/The_Joel_on_Software_Translation_Project:%E8%BB%9F%E9%AB%94%E4%BA%BA%E5%93%A1%E9%9D%A2%E8%A9%A6%E6%95%99%E6%88%B0%E5%AE%88%E5%89%87" target="_blank"&gt;〈軟體人員面試教戰守則〉&lt;/a&gt;中，思考怎樣是業界所需要的人。而勵志的&lt;a href="http://local.joelonsoftware.com/wiki/The_Joel_on_Software_Translation_Project:%E9%82%8A%E9%96%8B%E7%81%AB%E9%82%8A%E7%A7%BB%E5%8B%95" target="_blank"&gt;〈邊開火邊移動〉&lt;/a&gt;更鼓勵讀者不要擔心每天只前進一點點，重點是每天都前進一點點。除此之外，由於作者曾經在微軟工作過，許多寫到關於微軟的管理風格、策略的部分都看得很過癮啊！&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-9199930733660605840?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/9199930733660605840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/9199930733660605840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/9199930733660605840'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/09/blog-post.html' title='《約耳談軟體》'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6320380778673077712</id><published>2010-08-31T00:25:00.000+08:00</published><updated>2010-08-31T00:27:27.233+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='路上的風景'/><title type='text'>One more step ahead</title><content type='html'>&lt;p&gt;很開心又跨出多一步，終於from C to C++了。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6320380778673077712?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6320380778673077712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/one-more-step-ahead.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6320380778673077712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6320380778673077712'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/one-more-step-ahead.html' title='One more step ahead'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3305420030130470152</id><published>2010-08-31T00:13:00.001+08:00</published><updated>2010-08-31T00:14:25.833+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 121 - Pipe Fitters</title><content type='html'>&lt;p&gt;這題是數學題，給矩形的長和寬，問最多可以擺幾個直徑為1單位的圓圈。只需考慮題目提供的grid或skew兩種排列方式。&lt;/p&gt;  &lt;p&gt;值得一記的是，這題也算是我的第一個C++程式！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;測資 &amp;quot;0.9 10&amp;quot;，output是 &amp;quot;0 grid&amp;quot;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cmath&amp;gt;
using namespace std;

int skew(float width, float height);

int main()
{
  int p, count;
  char c, s[20];
  float side[2];
  
  p = count = 0;
  while( (c = getchar()) != EOF ){
    if( (c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9') || c == '.' )
      s[p++] = c;
    else if( c == ' ' ){
      if( p &amp;gt; 0 ){
        s[p] = '\0';
        sscanf(s, &amp;quot;%f&amp;quot;, &amp;amp;side[count++]);
        p = 0;
      }//if valid input
    }//else if c == '0'
    else if( c == '\n' ){
      if( p &amp;gt; 0 ){
        s[p] = '\0';
        sscanf(s, &amp;quot;%f&amp;quot;, &amp;amp;side[count]);
        
        int max, mtype = 0, tmp;
        char type[2][5] = {&amp;quot;grid&amp;quot;, &amp;quot;skew&amp;quot;};
        if( count == 0 ){
          max = (int)side[0] * (int)side[0];
          if( (tmp = skew(side[0], side[0])) &amp;gt; max ){
            max = tmp;
            mtype = 1;
          }
        }//if square
        else{
          max = (int)side[0] * (int)side[1];
          if( (tmp = skew(side[0], side[1])) &amp;gt; max ){
            max = tmp;
            mtype = 1;
          }
          if( (tmp = skew(side[1], side[0])) &amp;gt; max ){
            max = tmp;
            mtype = 1;
          }
        }//if rectangle
        
        cout &amp;lt;&amp;lt; max &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; type[mtype] &amp;lt;&amp;lt; '\n';
        p = count = 0;
      }//if valid input
    }//else if c == '\n'
    else ;
  }//while input
  
  return 0;
}

int skew(float width, float height){  
  if( width &amp;lt; 1.0 || height &amp;lt; 1.0 )
    return 0;
  
  int dh, sum = 0;
  float th;//height of triangle
  
  th = sqrt(3)/2;
  dh = (int)( (height-1)/th );
  dh++;
  
  sum += (int)width * dh;
  if( (width - (int)width) &amp;lt; 0.5 )
    sum -= (int)( dh/2 );
    
  return sum;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3305420030130470152?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3305420030130470152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-121-pipe-fitters.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3305420030130470152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3305420030130470152'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-121-pipe-fitters.html' title='ACM: 121 - Pipe Fitters'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1163008149553764216</id><published>2010-08-28T14:39:00.000+08:00</published><updated>2010-08-28T14:40:11.368+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>烏龍派出所片尾曲</title><content type='html'>&lt;p&gt;01〈スマイル〉&lt;/p&gt;  &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Xxgx3R9-_10?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Xxgx3R9-_10?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;02〈いいことあるさ〉&lt;/p&gt;  &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/iOAnkN6atAQ?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/iOAnkN6atAQ?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;03〈淑女の夢は万華鏡〉&lt;/p&gt;  &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/7kgE-ChD24w?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/7kgE-ChD24w?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;04〈ブウェーのビヤビヤ〉&lt;/p&gt;  &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ynQDkWqLErk?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ynQDkWqLErk?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1163008149553764216?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1163008149553764216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/blog-post_28.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1163008149553764216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1163008149553764216'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/blog-post_28.html' title='烏龍派出所片尾曲'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-8490091565218238877</id><published>2010-08-27T23:01:00.001+08:00</published><updated>2010-08-27T23:01:21.873+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Ruby筆記</title><content type='html'>&lt;p&gt;Ruby是一個跨平台的直譯式物件導向程式設計語言，訴求語法自然快捷，增進程式設計者的愉悅。   &lt;br /&gt;由Ruby寫成的Ruby on Rails(Rails/RoR)是open source的web application framework，由於能大幅減少網路應用服務的開發時間而受到歡迎。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;安裝Ruby&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.ruby-lang.org/zh_TW/downloads/"&gt;http://www.ruby-lang.org/zh_TW/downloads/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;IDE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;RadRails: &lt;a href="http://aptana.com/products/radrails"&gt;http://aptana.com/products/radrails&lt;/a&gt;    &lt;br /&gt;(跨平台的Ruby和Rails的IDE)&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;入門體驗&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tryruby.org/"&gt;Try Ruby&lt;/a&gt;: 15分鐘的線上即時Ruby體驗    &lt;br /&gt;&lt;a href="http://www.ruby-lang.org/zh_TW/documentation/quickstart/" target="_blank"&gt;二十分鐘 Ruby 體驗&lt;/a&gt;: 官網的入門教學&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;書&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.amazon.com/Beginning-Ruby-Novice-Professional/dp/1590597664" target="_blank"&gt;Beginning Ruby: From Novice to Professional&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://www.amazon.com/Programming-Ruby-1-9-Pragmatic-Programmers/dp/1934356085/" target="_blank"&gt;Programming Ruby 1.9: The Pragmatic Programmers' Guide&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;中文線上資源&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.ruby-lang.org/zh_TW" target="_blank"&gt;中文官方網站&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://ruby.tw/" target="_blank"&gt;Ruby Taiwan Community&lt;/a&gt;&lt;/p&gt; &lt;a href="http://blog.soft.idv.tw/?p=156" target="_blank"&gt;幾本不錯的Ruby和Ruby On Rails電子書下載&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-8490091565218238877?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/8490091565218238877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/ruby.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8490091565218238877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/8490091565218238877'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/ruby.html' title='Ruby筆記'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7480411689139082476</id><published>2010-08-27T21:20:00.001+08:00</published><updated>2010-08-27T21:21:51.248+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>My First Ruby Program</title><content type='html'>&lt;p&gt;用Ruby試寫了一個找質數的程式，再加了簡單排版功能讓輸出比較好看。用到10000000只是想測試Ruby的陣列可以開到這麼大，而最能感受到Ruby快靚正的地方，應該就在 i.to_s.length 這句了，只要一行就能知道數字長度！&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;Max = 10000000
num = []
length = 0

(Max+1).times { |i| num &amp;lt;&amp;lt; i }

2.upto(Max) do |i|
  if num[i] == i
    print i
    (i+i).step(Max, i) { |j| num[j] = 0 }
    
    #排版
    length += i.to_s.length
    if length &amp;gt; 40
      print &amp;quot;\n&amp;quot;
      length = 0
    else print &amp;quot; &amp;quot;
    end
  end
end&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7480411689139082476?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7480411689139082476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/my-first-ruby-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7480411689139082476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7480411689139082476'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/my-first-ruby-program.html' title='My First Ruby Program'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3296472127298873397</id><published>2010-08-26T19:01:00.000+08:00</published><updated>2010-08-26T19:02:40.876+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Notepad'/><title type='text'>Software Engineering</title><content type='html'>&lt;p&gt;軟體工程的目標在於在有限的時間、資源、人力下開發出達成預期目標的軟體。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Scope     &lt;br /&gt;&lt;/strong&gt;From &lt;a href="http://en.wikipedia.org/wiki/Software_engineering"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;1. Software requirements    &lt;br /&gt;&lt;strong&gt;2. &lt;a href="http://en.wikipedia.org/wiki/Software_design"&gt;Software design&lt;/a&gt;&lt;/strong&gt;     &lt;br /&gt;3. Software development     &lt;br /&gt;&lt;strong&gt;4. &lt;a href="http://en.wikipedia.org/wiki/Software_testing"&gt;Software testing&lt;/a&gt;&lt;/strong&gt;     &lt;br /&gt;5. Software maintenance     &lt;br /&gt;6. Software configuration management     &lt;br /&gt;7. Software engineering management     &lt;br /&gt;8. Software development process     &lt;br /&gt;9. Software engineering tools     &lt;br /&gt;10. Software quality&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;書      &lt;br /&gt;&lt;/strong&gt;轉自&amp;lt;&lt;a href="http://huan-lin.blogspot.com/2008/09/100.html"&gt;前 100 名最佳軟體工程書籍&lt;/a&gt;&amp;gt;&lt;/p&gt;  &lt;p&gt;1. Steve McConnell, Code Complete: A Practical Handbook of Software Construction    &lt;br /&gt;中文版：軟體建構之道 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2. Elisabeth Freeman, etc., Head First Design Patterns&lt;/strong&gt;     &lt;br /&gt;中文版：深入淺出設計模式 &lt;/p&gt;  &lt;p&gt;3. Steve McConnell, Rapid Development    &lt;br /&gt;中文版：軟體快速開發 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;4. Erich Gamma, Design Patterns: Elements of Reusable Object-Oriented Software&lt;/strong&gt;     &lt;br /&gt;中文版：物件導向設計模式 &lt;/p&gt;  &lt;p&gt;5. Bruce Schneier, Applied Cryptography: Protocols, Algorithms, and Source Code (2nd Edition) &lt;/p&gt;  &lt;p&gt;6. Robert C. Martin, Agile Software Development: Principles, Patterns and Practices    &lt;br /&gt;中文版：敏捷軟體開發－原則、樣式及實務 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;7. Joel Spolsky, Joel on Software      &lt;br /&gt;&lt;/strong&gt;中文版：&lt;a href="http://local.joelonsoftware.com/mediawiki/index.php/%E9%A6%96%E9%A0%81"&gt;約耳談軟體&lt;/a&gt;（網站） &lt;/p&gt;  &lt;p&gt;8. Tom DeMarco, Timothy Lister, Peopleware: Productive Projects and Teams (2nd Edition)    &lt;br /&gt;中文版：Peopleware： 腦力密集產業的人才管理之道 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;9. Frederick P. Brooks, The Mythical Man-Month, Anniversary Edition (2nd Edition)&lt;/strong&gt;     &lt;br /&gt;中文版：人月神話 &lt;/p&gt;  &lt;p&gt;10. Martin Fowler, Refactoring: Improving the Design of Existing Code    &lt;br /&gt;中文版：重構－改善既有程式的設計&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3296472127298873397?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3296472127298873397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/software-engineering.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3296472127298873397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3296472127298873397'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/software-engineering.html' title='Software Engineering'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3420066937380079470</id><published>2010-08-26T16:01:00.000+08:00</published><updated>2010-08-26T16:02:12.713+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM 20 題</title><content type='html'>&lt;p&gt;寫到了第二個10題，讚。111 ~ 120因為有許多simulation題，比前10題相對輕鬆一點點，但還是學到了LIS、尤拉路徑、接觸到簡化的TSP(Travelling Salesman Problem)問題，也練習不少recurssive。加油，總有一天要寫出runtime 0.000的code！&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3420066937380079470?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3420066937380079470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3420066937380079470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3420066937380079470'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-20.html' title='ACM 20 題'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7388563517540004388</id><published>2010-08-26T15:38:00.001+08:00</published><updated>2010-08-26T15:38:53.652+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 120 - Stacks of Flapjacks</title><content type='html'>&lt;p&gt;這一題是給一疊大小不一的鬆餅，要用整個堆疊旋轉的方式，讓鬆餅從小到大排序。輸出結果不需是最佳解，只要能夠讓鬆餅排序就可以了。我覺得寫這題就是頭腦要清楚啊，因為input資料是從top開始，但要輸出的flip數字卻要從bottom算起！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 30

int n, cake[MAX];

int makenum(int p, int *a);
void flipcake(int p);

int main(){
  int i, k, max, flag;
  int p, num[3];
  char c;

  n = p = flag = 0;
  while( (c = getchar()) != EOF ){
    if( c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9' ){
      num[p++] = c - '0';
    }/*if '0'&amp;lt;= c &amp;lt;='9'*/
    else if( c == ' ' ){
      cake[n++] = makenum(p, num);
      p = 0;
    }/*if c == ' '*/
    else if( c == '\n' ){
      if( p &amp;gt; 0 )
        cake[n++] = makenum(p, num);
      
      if( n &amp;gt; 0 ){
        printf(&amp;quot;%d&amp;quot;, cake[0]);
        for(i=1; i&amp;lt;n; i++)
          printf(&amp;quot; %d&amp;quot;, cake[i]);
        printf(&amp;quot;\n&amp;quot;);
        
        for(i=0; i&amp;lt;n; i++){
          max = 0;
          for(k=1; k&amp;lt;(n-i); k++){
            if( cake[k] &amp;gt; cake[max] )
              max = k;
          }/*k: find max pancake*/
          
          /*flip biggest pancake to top*/
          if( max&amp;gt;0 &amp;amp;&amp;amp; max&amp;lt;(n-i-1) ){
            flipcake(max);
            if( flag == 1 ) printf(&amp;quot; &amp;quot;);
            else flag = 1;
            printf(&amp;quot;%d&amp;quot;, n-max);
          }
          /*flip biggest pancake to current bottom*/
          if( max&amp;lt;(n-i-1) ){
            flipcake(n-i-1);
            if( flag == 1 ) printf(&amp;quot; &amp;quot;);
            else flag = 1;
            printf(&amp;quot;%d&amp;quot;, i+1);
          }
        }/*j: sort the pancake*/
        
        if( flag == 1 ) printf(&amp;quot; &amp;quot;);
        printf(&amp;quot;0\n&amp;quot;);
      }/*if valid input*/
            
      n = p = flag = 0;
    }/*if c == '\n'*/
    else ;
  }/*while*/
  
  exit(0);
}

int makenum(int p, int *a){
  if( p == 3 )
    return 100;
  if( p == 2 )
    return (a[0]*10 + a[1]);
  return a[0];
}

void flipcake(int p){
  int i, j, tmp;
  
  for(i=0, j=p; i&amp;lt;=j; i++, j--){
    tmp = cake[i];
    cake[i] = cake[j];
    cake[j] = tmp;
  }
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7388563517540004388?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7388563517540004388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-120-stacks-of-flapjacks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7388563517540004388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7388563517540004388'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-120-stacks-of-flapjacks.html' title='ACM: 120 - Stacks of Flapjacks'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-3559701598893119846</id><published>2010-08-26T12:59:00.000+08:00</published><updated>2010-08-26T13:00:01.515+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 119 - Greedy Gift Givers</title><content type='html'>&lt;p&gt;也是很單純的simulation題，唯一要注意的是gift taker數量可能為0，要排除除以0的情況。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#define MAX_P 10
#define MAX_LEN 12

int n;
char names[MAX_P][MAX_LEN+1];

int findname(char *name);

int main(){
  int i, j, k, flag;
  int gift, taker, net[MAX_P];
  char s[MAX_LEN+1];
  
  flag = 0;
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;n) != EOF ){
    if( flag == 1 )
      printf(&amp;quot;\n&amp;quot;);
    
    for(i=0; i&amp;lt;n; i++){
      scanf(&amp;quot;%s&amp;quot;, names[i]);
      net[i] = 0;
    }
    
    for(i=0; i&amp;lt;n; i++){
      scanf(&amp;quot;%s %d %d&amp;quot;, s, &amp;amp;gift, &amp;amp;taker);
      k = findname(s);
      
      if( taker != 0 ){
        net[k] -= gift;
        net[k] += (gift % taker);
        gift /= taker;
      }
      
      for(j=0; j&amp;lt;taker; j++){
        scanf(&amp;quot;%s&amp;quot;, s);
        k = findname(s);
        net[k] += gift;
      }/*j: give gift to taker*/
    }/*i*/
    
    for(i=0; i&amp;lt;n; i++)
      printf(&amp;quot;%s %d\n&amp;quot;, names[i], net[i]);
    
    flag = 1;
  }/*while more groups data*/
  
  exit(0);
}

int findname(char *s){
  int i;
  
  for(i=0; i&amp;lt;n; i++)
    if( strcmp(s, names[i]) == 0 )
      return i;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-3559701598893119846?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/3559701598893119846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-119-greedy-gift-givers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3559701598893119846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/3559701598893119846'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-119-greedy-gift-givers.html' title='ACM: 119 - Greedy Gift Givers'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-448286759117040692</id><published>2010-08-26T12:53:00.000+08:00</published><updated>2010-08-26T12:54:05.509+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 118 - Mutant Flatworld Explorers</title><content type='html'>&lt;p&gt;很單純的simulation題，就是照著規則去模擬。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#define MAX 50
#define MAX_LEN 100

int main(){
  int i, len;
  int mx, my, x, y, dir, t[MAX+1][MAX+1];
  int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1, 0};
  char c, cmd[MAX_LEN], nesw[4]=&amp;quot;NESW&amp;quot;;
  
  scanf(&amp;quot;%d %d&amp;quot;, &amp;amp;mx, &amp;amp;my);
  while( scanf(&amp;quot;%d %d %c&amp;quot;, &amp;amp;x, &amp;amp;y, &amp;amp;c) != EOF ){
    scanf(&amp;quot;%s&amp;quot;, cmd);
    
    for(i=0; i&amp;lt;4; i++)
      if( c == nesw[i] )
        dir = i;
    
    len = strlen(cmd);
    for(i=0; i&amp;lt;len; i++){
      switch ( cmd[i] ){
        case 'L':
          dir--;
          break;
        case 'R':
          dir++;
          break;
        case 'F':
          while( dir &amp;lt; 0 )
            dir += 4;
          dir = dir % 4;
          if( (x+dx[dir])&amp;lt;0 || (x+dx[dir])&amp;gt;mx || (y+dy[dir])&amp;lt;0 || (y+dy[dir])&amp;gt;my ){
            if( t[x][y] != 1 ){
              t[x][y] = 1;
              i = len;
            }
          }
          else{
            x += dx[dir];
            y += dy[dir];
          }
          break;
        default: break;
      }/*switch*/
    }/*i*/
    
    while( dir &amp;lt; 0 )
      dir += 4;
    dir = dir % 4;
    printf(&amp;quot;%d %d %c&amp;quot;, x, y, nesw[dir]);
    if( i &amp;gt; len )
      printf(&amp;quot; LOST&amp;quot;);
    printf(&amp;quot;\n&amp;quot;);
  }/*while*/
  
  exit(0);
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-448286759117040692?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/448286759117040692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-118-mutant-flatworld-explorers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/448286759117040692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/448286759117040692'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-118-mutant-flatworld-explorers.html' title='ACM: 118 - Mutant Flatworld Explorers'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6313637722424041919</id><published>2010-08-25T21:20:00.000+08:00</published><updated>2010-08-25T21:23:19.349+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 117 - The Postal Worker Rings Once</title><content type='html'>&lt;p&gt;這一題是給許多條「街道」，找出將每條街至少走過一次，並回到原點的最短路徑，傳回路徑總長。可以視作一個graph，找出將每個邊至少走一次，並回到原點的最小路徑權重值。這題有以下背景知識：&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Eulerian Circuit/Eulerian Path (尤拉路徑)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;題目有兩個要點，將這題指向尤拉路徑:    &lt;br /&gt;1. In each postal route there will be a path between all intersections, i.e., the intersections are connected. (所有的道路可以接通，即是這是一個連通圖)     &lt;br /&gt;2. There will be at most two intersections with odd degree. All other intersections will have even degree, i.e., an even number of streets meeting at that intersection. (圖裡最多只有兩個點會有奇數個邊，其他點都會有偶數個邊)&lt;/p&gt;  &lt;p&gt;Eulerian Circuit是判斷一個圖(無向圖)存不存在一個路徑，能從一點開始不經過重複的邊走完全圖，再回到原點。存在的條件如下:    &lt;br /&gt;&lt;strong&gt;圖形上每一個端點(vertex)皆有偶數個邊(degree為偶數)&lt;/strong&gt;     &lt;br /&gt;因為若有一個端點有奇數個邊，勢必有一條路只能去不能回。&lt;/p&gt;  &lt;p&gt;Eulerian Path(Eulerian Chain)則是一筆劃問題，找圖上是否存在一個路徑，從一點開始不經過重複的邊走完全圖，但不一定要回到原點。存在的條件如下:    &lt;br /&gt;&lt;strong&gt;圖形上最多只有兩個端點有奇數個邊，其餘端點皆有偶數個邊      &lt;br /&gt;&lt;/strong&gt;而在有端點為奇數degree的情況下，Eulerian Path必定從奇數degree的端點開始，並且結束於奇數degree的端點。因為拿掉造成奇數degree的邊，圖形就可以回到原點，因此Eulerian Path可以想成是先走完一圈回到原點，再去特別走「多出來」的路徑，所以一定開始結束在奇數degree的端點。&lt;/p&gt;  &lt;p&gt;因此這題是Eulerian Path的問題，當所有端點的degree皆為偶數時，最短路徑即是所有路徑的總和；而因為需要回到原點，當有奇數degree端點存在時，需再找出奇數degree端點之間的最小路徑，以回到原點。&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Handshaking Lemma (握手定裡)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;題目寫了&amp;quot;There will be at most two intersections with odd degree&amp;quot;，是「最多」兩個端點有奇數degree，但只有一個端點有奇數degree的情況是否可能存在呢？&lt;/p&gt;  &lt;p&gt;從handshaking lemma可以了解這個情況是不可能的，因為好比兩人握手的時候，必然是兩個人都伸出手來，因此一個端點有奇數個邊，也必然有相應的點去連接那個邊，雙向計算的結果是，任何一個(無向)圖，擁有奇數個邊的端點數是偶數！&lt;/p&gt;  &lt;p&gt;因此這個題目只有兩種情況：全部端點皆有偶數個邊，或只有兩個端點有奇數個邊。&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;寫出來Runtime 0.008，這題平均runtime超短的，要怎樣才能寫到0.000的境界呢！！我想也許在找shortest path的部分還可以再更快一點。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCES&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://1stprinciples.wordpress.com/uva-online-judge-discussion/117-the-postal-worker-rings-once/" target="_blank"&gt;117 - The Postal Worker Rings Once&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.csie.ntnu.edu.tw/~u91029/Circuit.html#a3" target="_blank"&gt;Euler Circuit / Euler Path&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Handshaking_lemma" target="_blank"&gt;Handshaking lemma&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#define MAX 26
#define MAX_LEN 1000

int t[MAX][MAX], od[2];

void initialize(void);
int odegree(void);
int shortest(int a, int b);

int main(){
  int i, j;
  int sum, len;
  char s[MAX_LEN];
  
  sum = 0;
  initialize();
  while( scanf(&amp;quot;%s&amp;quot;, s) != EOF ){
    if( strcmp(s, &amp;quot;deadend&amp;quot;) == 0 ){
      if( odegree() == 1 ){
        sum += shortest(od[0], od[1]);
        printf(&amp;quot;%d\n&amp;quot;, sum);
      }
      else
        printf(&amp;quot;%d\n&amp;quot;, sum);
      
      sum = 0;
      initialize();
    }/*output*/
    else{
      len = strlen(s);
      sum += len;
      t[ s[0]-'a' ][ s[len-1]-'a' ] = t[ s[len-1]-'a' ][ s[0]-'a' ] = len;
    }/*read data*/
  }/*while input data*/
  
  exit(0);
}

void initialize(void){
  int i, j;
  
  for(i=0; i&amp;lt;MAX; i++)
    for(j=0; j&amp;lt;MAX; j++)
      t[i][j] = 0;
  return;
}

int odegree(void){
  int i, j, k, d;
  
  d = 0;
  for(i=0; i&amp;lt;MAX; i++){
    k = 0;
    for(j=0; j&amp;lt;MAX; j++)
      if( t[i][j] &amp;gt; 0 )
        k++;
    if( k%2 == 1 )
      od[d++] = i;
  }
  
  if( d &amp;gt; 0 )
    return 1;
  return 0;
}

int shortest(int a, int b){
  int i, j, k, tmp;
  
  for(k=0; k&amp;lt;MAX; k++){
    for(i=0; i&amp;lt;MAX; i++){
      for(j=0; j&amp;lt;MAX; j++){
        if( t[i][k]*t[k][j] != 0 ){
          tmp = t[i][k] + t[k][j];
          if( tmp &amp;lt; t[i][j] || t[i][j] == 0 )
            t[i][j] = tmp;
        }
      }/*j*/
    }/*i*/
  }/*k*/
  
  return t[a][b];
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6313637722424041919?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6313637722424041919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-117-postal-worker-rings-once.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6313637722424041919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6313637722424041919'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-117-postal-worker-rings-once.html' title='ACM: 117 - The Postal Worker Rings Once'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1814043065851457678</id><published>2010-08-25T00:14:00.001+08:00</published><updated>2010-08-25T00:14:54.807+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 116 - Unidirectional TSP</title><content type='html'>&lt;p&gt;這一題要找一個table從左走到右的最小和路徑。題目寫的很像可以用brute force，但用brute force會超過time limit。後來想到DP的方法，很開心。DP真是一種很神奇的概念。&lt;/p&gt;  &lt;p&gt;寫出來後一直runtime error，看很久才發現是表格頭接尾，尾接頭的部分沒有用餘數的方法讓他自動接，造成有漏洞會陣列越界讀取。改成餘數的方法就解決了。果然越好的演算法越不會有奇怪的洞啊。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

#define MAX_M 10
#define MAX_N 100

int main(){
  int i, j, k, min, tmp;
  int m, n, t[MAX_M][MAX_N], p[MAX_M][MAX_N];
  int mod[2] = {-1, 1};
  
  while( scanf(&amp;quot;%d %d&amp;quot;, &amp;amp;m, &amp;amp;n) == 2 ){
    for(i=0; i&amp;lt;m; i++)
      for(j=0; j&amp;lt;n; j++)
        scanf(&amp;quot;%d&amp;quot;, &amp;amp;t[i][j]);
    
    for(j=(n-2); j&amp;gt;=0; j--){
      for(i=0; i&amp;lt;m; i++){
        min = i;
        for(k=0; k&amp;lt;2; k++){
          tmp = (i+mod[k]+m) % m;
          if( t[tmp][j+1] &amp;lt; t[min][j+1] )
            min = tmp;
          else if( t[tmp][j+1] == t[min][j+1] )
            if( tmp &amp;lt; min )
              min = tmp;
        }/*k*/
        p[i][j] = min;
        t[i][j] += t[min][j+1];
      }/*i: row*/
    }/*j: col*/
    
    k = 0;
    for(i=1; i&amp;lt;m; i++)
      if( t[i][0] &amp;lt; t[k][0] )
        k = i;
    
    j = k;
    printf(&amp;quot;%d&amp;quot;, k+1);
    for(i=0; i&amp;lt;n-1; i++){
      printf(&amp;quot; %d&amp;quot;, p[j][i]+1);
      j = p[j][i];
    }
    printf(&amp;quot;\n%d\n&amp;quot;, t[k][0]);
  }/*while input data*/ 
  
  exit(0);
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1814043065851457678?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1814043065851457678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-116-unidirectional-tsp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1814043065851457678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1814043065851457678'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-116-unidirectional-tsp.html' title='ACM: 116 - Unidirectional TSP'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-44401042357741559</id><published>2010-08-24T18:12:00.001+08:00</published><updated>2010-08-24T18:12:17.653+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='黑夜'/><title type='text'>Mourning</title><content type='html'>&lt;p&gt;Mourning to the hostage victims at Manila. May their souls rest in peace, and their families be comforted…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-44401042357741559?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/44401042357741559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/mourning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/44401042357741559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/44401042357741559'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/mourning.html' title='Mourning'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6594743598359483972</id><published>2010-08-24T16:45:00.001+08:00</published><updated>2010-08-24T16:45:57.681+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 115 - Climbing Trees</title><content type='html'>&lt;p&gt;這題寫出來也很感動，原因一是自己想到演算法解出了graph題！原因二是寫完以後de了超久的bug，明明自己測試output都正確，一直找不到runtime error的原因。看超久才發現原來是把一個變數放錯資料型別，改了以後總算AC了！&lt;/p&gt;  &lt;p&gt;我用一個一維陣列存每個child的parent，再不斷trace。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#define MAX_NAMES 300
#define LEN_NAME 31

int tree[MAX_NAMES], maxn;
char name[MAX_NAMES][LEN_NAME+1];

int addname(char *s);
int findname(char *s);
void qry(int p, int q);
void showtrace(int t);
int isdescendent(int p, int q, char *s);
int iscousin(int p, int q);

int main(){
  int pk, qk;
  char p[LEN_NAME+1], q[LEN_NAME+1];
  
  maxn = 0;
  while( scanf(&amp;quot;%s %s&amp;quot;, p, q) == 2 ){
    if( strcmp(p, &amp;quot;no.child&amp;quot;) == 0 )
      break;
    else{
      pk = addname(p);
      qk = addname(q);
      tree[pk] = qk;
    }
  }/*while parent-child pairs input*/
  
  /*read query*/
  while( scanf(&amp;quot;%s %s&amp;quot;, p, q) == 2 ){
    pk = findname(p);
    qk = findname(q);
    qry(pk, qk);
  }/*while query input*/
  
  exit(0);
}

int addname(char *s){
  int i;
  
  /*check if name exists*/
  for(i=0; i&amp;lt;maxn; i++)
    if( strcmp(s, name[i]) == 0 )
      return i;
  
  /*add new name*/
  strcpy(name[maxn], s);
  tree[maxn] = maxn;
  maxn++;
  
  return (maxn-1);
}

int findname(char *s){
  int i;
  
  for(i=0; i&amp;lt;maxn; i++)
    if( strcmp(s, name[i]) == 0 )
      return i;
  
  return -1;
}

void qry(int p, int q){ 
  if( p != -1 &amp;amp;&amp;amp; q != -1 ){
    if( tree[p] == tree[q] ){
      printf(&amp;quot;sibling\n&amp;quot;);
      return;
    }
    if( isdescendent(p, q, &amp;quot;child&amp;quot;) == 1 )
      return;
    if( isdescendent(q, p, &amp;quot;parent&amp;quot;) == 1 )
      return;
    if( iscousin(p, q) == 1 )
      return;
  }/*if p, q != -1 */
  
  printf(&amp;quot;no relation\n&amp;quot;);
  return;
}

void showtrace(int t){
  int i;
  
  if( t == 0 )
    return;
  for(i=t; i&amp;gt;1; i--)
    printf(&amp;quot;great &amp;quot;);
  printf(&amp;quot;grand &amp;quot;);
}

int isdescendent(int p, int q, char *s){
  int tp, trace;
  
  tp = p;
  trace = 0;
  while( tree[tp] != tp ){
    tp = tree[tp];
    if( tp == q ){
      showtrace(trace);
      printf(&amp;quot;%s\n&amp;quot;, s);
      return 1;
    }
    trace++;
  }
  
  return 0;
}

int iscousin(int p, int q){
  int tp, tq, m, n;
  
  tp = p;
  tq = q;
  m = n = 0;
  while( tp != tree[tp] ){
    tp = tree[tp];
    while( tq != tree[tq] ){
      tq = tree[tq];
      if( tp == tq ){
        if( m &amp;gt; n ){
          printf(&amp;quot;%d cousin &amp;quot;, n);
          printf(&amp;quot;removed %d\n&amp;quot;, (m-n));
        }
        else if( m == n )
          printf(&amp;quot;%d cousin\n&amp;quot;, m);
        else{
          printf(&amp;quot;%d cousin &amp;quot;, m);
          printf(&amp;quot;removed %d\n&amp;quot;, (n-m));
        }
        return 1;
      }/*if common ancestor found*/
      n++;
    }/*while: trace q*/      
    tq = q;
    n = 0;
    m++;
  }/*while: trace p*/
  
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6594743598359483972?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6594743598359483972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-115-climbing-trees.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6594743598359483972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6594743598359483972'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-115-climbing-trees.html' title='ACM: 115 - Climbing Trees'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1483671251377856001</id><published>2010-08-23T22:08:00.001+08:00</published><updated>2010-08-23T22:08:44.842+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 114 - Simulation Wizardry</title><content type='html'>&lt;p&gt;相對輕鬆一點的有趣Simulation題目，就是要仔細把文字敘述看清楚，了解遊戲規則。我覺得最重要的應該是這句話:&lt;/p&gt;  &lt;p&gt;&amp;quot;A ball ''hits'' an obstacle during a timestep when it would otherwise move on top of the bumper or wall grid point. A hit causes the ball to ``rebound'' by turning right (clockwise) 90 degrees, without ever moving on top of the obstacle and without changing position (only the direction changes as a result of a rebound).&amp;quot;&lt;/p&gt;  &lt;p&gt;即是球撞到障礙物(牆或bumper)，都會留在原位不動，只改變下一步的方向。&lt;/p&gt;  &lt;p&gt;其他就是照著遊戲規則simulation了。Runtime 0.044，Ranking進前100，開心開心。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 50

#define GAME 0
#define VALUE 1
#define COST 2

#define RIGHT 0
#define UP 1
#define LEFT 2
#define DOWN 3

int m, n, g[3][MAX+1][MAX+1];

int pinball(int x, int y, int dir, int life);
void nextmove(int x, int y, int dir, int *arr);
int chgdir(int dir);

int main(){
  int i, j, t;
  int x, y, v1, v2, sum;
  
  scanf(&amp;quot;%d %d&amp;quot;, &amp;amp;m, &amp;amp;n);
  scanf(&amp;quot;%d&amp;quot;, &amp;amp;t); /*cost of hitting the wall*/
  
  /*initialize the pinball game &amp;amp; set walls*/
  for(i=1; i&amp;lt;=m; i++){
    g[GAME][1][i] = g[GAME][n][i] = 1;
    g[VALUE][1][i] = g[VALUE][n][i] = 0;
    g[COST][1][i] = g[COST][n][i] = t;
  }
  for(i=2; i&amp;lt;n; i++){
    for(j=1; j&amp;lt;=m; j++){
      if( j==1 || j==m ){
        g[GAME][i][j] = 1;
        g[VALUE][i][j] = 0;
        g[COST][i][j] = t;
      }
      else
        g[GAME][i][j] = g[VALUE][i][j] = g[COST][i][j] = 0;
    }/*j*/
  }/*i*/
  
  /*read bumpers*/
  scanf(&amp;quot;%d&amp;quot;, &amp;amp;t); /*number of bumpers*/
  for(i=0; i&amp;lt;t; i++){
    scanf(&amp;quot;%d %d %d %d&amp;quot;, &amp;amp;x, &amp;amp;y, &amp;amp;v1, &amp;amp;v2);
    
    g[GAME][x][y] = 1;
    g[VALUE][x][y] = v1;
    g[COST][x][y] = v2;
  }/*i*/
  
  /*read balls*/
  sum = t = 0;
  while( scanf(&amp;quot;%d %d %d %d&amp;quot;, &amp;amp;x, &amp;amp;y, &amp;amp;v1, &amp;amp;v2) != EOF ){
    t = pinball(x, y, v1, v2);
    sum += t;
    printf(&amp;quot;%d\n&amp;quot;, t);
  }/*while*/
  
  printf(&amp;quot;%d\n&amp;quot;, sum);
  exit(0);
}

int pinball(int x, int y, int dir, int life){
  int v, move[2];
  
  v = 0;
  while( life &amp;gt; 1 ){
    nextmove(x, y, dir, move);
    if( g[GAME][ move[0] ][ move[1] ] == 1 ){   
      life -= g[COST][ move[0] ][ move[1] ];
      v += g[VALUE][ move[0] ][ move[1] ];
      dir = chgdir(dir);
    }
    else{
      x = move[0];
      y = move[1];
    }
    
    life--;
  }/*while life &amp;gt; 1*/
  
  return v;
}

void nextmove(int x, int y, int dir, int *arr){
  arr[0] = x;
  arr[1] = y;
  
  switch (dir) {
    case RIGHT:
      arr[0]++;
      break;
    case UP:
      arr[1]++;
      break;
    case LEFT:
      arr[0]--;
      break;
    case DOWN:
      arr[1]--;
      break;
    default: break;
  }
}

int chgdir(int dir){
  if( dir == RIGHT )
    dir = DOWN;
  else
    dir--;
    
  return dir;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1483671251377856001?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1483671251377856001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-114-simulation-wizardry.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1483671251377856001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1483671251377856001'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-114-simulation-wizardry.html' title='ACM: 114 - Simulation Wizardry'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1293410500835338858</id><published>2010-08-22T19:34:00.001+08:00</published><updated>2010-08-22T19:34:42.468+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 111 – History Grading</title><content type='html'>&lt;p&gt;這一題即是稍做變化的Longest Increasing Subsequence (LIS)問題，但要注意的是input資料。input資料是Event的&lt;strong&gt;Order&lt;/strong&gt;:&lt;/p&gt;  &lt;p&gt;Event: &lt;em&gt;1 2 3 4 5 6 7 8 9 10      &lt;br /&gt;&lt;/em&gt;Order: 3 1 2 4 9 5 10 6 8 7&lt;/p&gt;  &lt;p&gt;即是Event by Order是: &lt;em&gt;2, 3, 1, 4, 6, 8, 10, 9, 5, 7&lt;/em&gt;。學生的回答也需要做如此的調整，比對出來才是正確的解答。原本沒有搞清楚，就想不通為什麼sample output跟自己算的答案不一樣了！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.csie.ntnu.edu.tw/~u91029/LongestIncreasingSubsequence.html"&gt;Longest Increasing Subsequence&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 20

int main(){
  int i, j, t;
  int n, c[MAX+1], r[MAX+1], lis[MAX+1], max;
  
  scanf(&amp;quot;%d&amp;quot;, &amp;amp;n);
  
  /*Read Correct Order*/
  for(i=1; i&amp;lt;=n; i++)
    scanf(&amp;quot;%d&amp;quot;, &amp;amp;c[i]);
    
  /*Read Student Response*/
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;t) != EOF){
    r[t] = 1;
    max = lis[1] = 1;
    for(i=2; i&amp;lt;=n; i++){
      scanf(&amp;quot;%d&amp;quot;, &amp;amp;t);
      r[t] = i;
      lis[i] = 1;
    }
    
    for(i=2; i&amp;lt;=n; i++){
      for(j=1; j&amp;lt;i; j++)
        if( c[ r[i] ] &amp;gt; c[ r[j] ] )
          if( lis[i] &amp;lt; (lis[j] + 1) )
            lis[i] = lis[j] + 1;
      
      if( max &amp;lt; lis[i] )
        max = lis[i];
    }/*i*/
       
    printf(&amp;quot;%d\n&amp;quot;, max);
  }/*while*/

  exit(0);
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1293410500835338858?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1293410500835338858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-111-history-grading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1293410500835338858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1293410500835338858'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-111-history-grading.html' title='ACM: 111 – History Grading'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6791934864111510042</id><published>2010-08-22T19:19:00.001+08:00</published><updated>2010-08-22T19:19:26.031+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 112 - Tree Summing</title><content type='html'>&lt;p&gt;這題要讀取以字串表現的binary tree，並找出是否有root-to-leaf path能產生指定的數字和。因為字串跟數字混在一起，如何處理字串可說是這題的罩門，但其實想清楚了這題S-expression的模式，字串處理起來就沒有想像中的複雜了。&lt;/p&gt;  &lt;p&gt;因為原本卡在如何擷取字串，也是第一次寫bin tree的東西，所以寫出來很開心！再進了百大，超超興奮！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;1. 數字會有負數    &lt;br /&gt;2. 注意 0 () 的測資，output應該要是 no&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

int a, found;

int tree(int parent_sum);
int makenum(int *a, int n, int sign);

int main(){
  char c;
  
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;a) != EOF ){
    while( (c = getchar()) !=EOF )
      if( c == '(' )
        break;
    
    found = 0;
    tree(0);
    if( found == 1 )
      printf(&amp;quot;yes\n&amp;quot;);
    else
      printf(&amp;quot;no\n&amp;quot;);
  }/*while*/
  
  exit(0);
}

/*return 0 if is empty node*/
int tree(int p){
  int sign, line[10], e, num;
  int flag, le, re;
  char c;
  
  flag = le = re = 1;
  sign = 1;
  e = num = 0;
  while( flag == 1 ){
    c = getchar();
    
    if( c == '-' )
      sign = -1;
    else if( c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9' ){
      line[e] = c - '0';
      e++;
    }
    else if( c == '(' ){
      /*make number*/
      num = makenum(line, e, sign);
      
      /*left tree*/
      if ( tree( num+p ) == 0 )
        le = 0;

      /*read '('*/
      while( (c = getchar()) !=EOF )
        if( c == '(' )
          break;

      /*right tree*/
      if ( tree( num+p ) == 0 )
        re = 0;
    }
    else if( c == ')' )
      flag = 0;
    else ;
  }/*while flag is 1*/
  
  if( (le + re == 0) &amp;amp;&amp;amp; ((num+p) == a) ){
    found = 1;
    return 1;
  }
  
  if( e == 0 )
    return 0;
    
  return 1;
}

int makenum(int *a, int n, int sign){
  int i, j, p, r;
  
  r = a[n-1];
  p = 1;
  for(i=0; i&amp;lt;(n-1); i++){
    for(j=1; j&amp;lt;=(n-i-1); j++)
      p *= 10;
    r += ( a[i] * p );
  }
  r *= sign;
  
  return r;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6791934864111510042?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6791934864111510042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-112-tree-summing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6791934864111510042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6791934864111510042'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-112-tree-summing.html' title='ACM: 112 - Tree Summing'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7846338748800160035</id><published>2010-08-20T17:24:00.000+08:00</published><updated>2010-08-20T17:25:26.379+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM 第一個10題</title><content type='html'>&lt;p&gt;寫到了第一個10題！目前暫缺還找不到WA原因的107，不然就有100 - 110連號了！一步一腳印覺得學了很多，Floyd-Warshall、Kadane’s Algorithm、Graham Scan、Number Theory… 很有趣，也有嚐到一點小小的甜頭，繼續加油加油，要看到第二個10題。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7846338748800160035?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7846338748800160035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7846338748800160035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7846338748800160035'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-10.html' title='ACM 第一個10題'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1023956396726647348</id><published>2010-08-20T17:06:00.001+08:00</published><updated>2010-08-20T17:06:50.157+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 110 - Meta-Loopless Sorts</title><content type='html'>&lt;p&gt;這題要寫出一個程式generate另一段程式碼。練習遞迴。Runtime 0.084，Ranking進入前100，超開心。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 8

void showarr(int n, int *array);
void showspace(int sp);
void copyarr(int n, int *to, int *frm);
void insertarr(int n, int position, int end, int k, int *array);
void showmeta(int n, int pos, int *array);

int main(){
  int i, j;
  int m, n, a[MAX];
  
  scanf(&amp;quot;%d&amp;quot;, &amp;amp;m);
  
  for(i=0; i&amp;lt;m; i++){
    scanf(&amp;quot;%d&amp;quot;, &amp;amp;n);
    
    for(j=0; j&amp;lt;n; j++)
      a[j] = j;
    
    if( i &amp;gt; 0 )
      printf(&amp;quot;\n&amp;quot;);
        
    printf(&amp;quot;program sort(input,output);\n&amp;quot;);
    printf(&amp;quot;var\n&amp;quot;);
    showarr(n, a);
    printf(&amp;quot; : integer;\n&amp;quot;);
    printf(&amp;quot;begin\n&amp;quot;);
    printf(&amp;quot;  readln(&amp;quot;);
    showarr(n, a);
    printf(&amp;quot;);\n&amp;quot;);
    
    if( n == 1 )
      printf(&amp;quot;  writeln(a)\n&amp;quot;);
    else
      showmeta(n, 1, a);
    printf(&amp;quot;end.\n&amp;quot;);
  }/*i: m inputs*/
  
  exit(0);
}

void showarr(int n, int *arr){
  int i;
  
  printf(&amp;quot;%c&amp;quot;, 'a'+arr[0]);
  for(i=1; i&amp;lt;n; i++)
    printf(&amp;quot;,%c&amp;quot;, 'a'+arr[i]);
}

void showspace(int sp){
  int i;
  
  for(i=1; i&amp;lt;=sp; i++)
    printf(&amp;quot;  &amp;quot;);
}

void copyarr(int n, int *to, int *frm){
  int i;
  
  for(i=0; i&amp;lt;n; i++)
    to[i] = frm[i];
}

void insertarr(int n, int p, int e, int k, int *arr){
  int i;
  
  if( p == e )
    arr[p] = k;
  else{
    for(i=e; i&amp;gt;p; i--)
      arr[i] = arr[i-1];
    arr[p] = k;
  }
}

void showmeta(int n, int p, int *arr){
  int i, cpy[MAX];
  
  if( p == (n-1) ){
    for(i=p; i&amp;gt;=0; i--){
      copyarr(n, cpy, arr);
      insertarr(n, i, p, p, cpy);
      
      showspace(p);
      if( i == p )
        printf(&amp;quot;if %c &amp;lt; %c then\n&amp;quot;, 'a'+cpy[i-1], 'a'+p);
      else if( i == 0 )
        printf(&amp;quot;else\n&amp;quot;);
      else
        printf(&amp;quot;else if %c &amp;lt; %c then\n&amp;quot;, 'a'+cpy[i-1], 'a'+p);
      
      showspace(p+1);
      printf(&amp;quot;writeln(&amp;quot;);
      showarr(n, cpy);
      printf(&amp;quot;)\n&amp;quot;);
    }/*i*/
  }
  else{
    for(i=p; i&amp;gt;=0; i--){
      copyarr(n, cpy, arr);
      insertarr(n, i, p, p, cpy);
      
      showspace(p);
      if( i == p )
        printf(&amp;quot;if %c &amp;lt; %c then\n&amp;quot;, 'a'+cpy[i-1], 'a'+p);
      else if( i == 0 )
        printf(&amp;quot;else\n&amp;quot;);
      else
        printf(&amp;quot;else if %c &amp;lt; %c then\n&amp;quot;, 'a'+cpy[i-1], 'a'+p);
      
      showmeta(n, p+1, cpy);
    }/*i*/
  }
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1023956396726647348?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1023956396726647348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-110-meta-loopless-sorts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1023956396726647348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1023956396726647348'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-110-meta-loopless-sorts.html' title='ACM: 110 - Meta-Loopless Sorts'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-954135214695702083</id><published>2010-08-19T18:50:00.000+08:00</published><updated>2010-08-19T18:53:03.696+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 109 – SCUD Buster</title><content type='html'>&lt;p&gt;這題寫出來超想放煙火慶祝的！學了Convex Hull、Graham Scan。生平第一次覺得外積是這麼有用、了不起兼神奇的發明(發現?)啊。只需要乘法，就可以找出兩個向量的角度關係，因此可以避免用到除法的機器浮點數問題，這實在是太神奇了。&lt;/p&gt;  &lt;p&gt;一次AC，感動。不過是超嫩的Runtime 0.016，我確定單在sorting就有很大的進步空間。但能夠把一組一組零散的座標，讓電腦連成一個圖形，再算出面積，相當有成就感。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;REFERENCES&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://par.cse.nsysu.edu.tw/~homework/algo01/9037621/html/Graham_Scan.htm" target="_blank"&gt;Graham Scan&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.csie.nctu.edu.tw/~sctsai/adprog/notes/CompGeo.ppt" target="_blank"&gt;Computational Geometry (ppt)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX_KINGDOM 20
#define MAX_VERTEX 100

int k, g[MAX_KINGDOM][MAX_VERTEX][2], gn[MAX_KINGDOM];

int findaim(int x, int y);
int isinside(int kingdom, int x, int y);
float findarea(int kingdom);

int main(){
  int i, j, s, tmp, min;
  int v, mx, my, at;
  int vx[MAX_VERTEX][2], attack[MAX_KINGDOM];
  float tot;
  
  /*Kingdom data*/
  v = 0;
  k = -1;
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;v)!=EOF &amp;amp;&amp;amp; v!=-1 ){
    k++;
    
    for(i=0; i&amp;lt;v; i++)
      scanf(&amp;quot;%d %d&amp;quot;, &amp;amp;vx[i][0], &amp;amp;vx[i][1]);
    
    /*find lowest point; if more than one point are the lowest, find the most left one*/
    min = 0;
    for(i=1; i&amp;lt;v; i++){
      if( vx[i][1] &amp;lt; vx[min][1] )
        min = i;
      else if( vx[i][1] == vx[min][1] )
        if( vx[i][0] &amp;lt; vx[min][0] )
          min = i;
    }
    if( min != 0 ){
      tmp = vx[min][0];
      vx[min][0] = vx[0][0];
      vx[0][0] = tmp;
      
      tmp = vx[min][1];
      vx[min][1] = vx[0][1];
      vx[0][1] = tmp;
    }
    
    /*sort rest points by counter clockwise with outer product*/
    for(i=1; i&amp;lt;v; i++){
      min = i;
      for(j=(i+1); j&amp;lt;v; j++){
        tmp = ( (vx[min][0]-vx[0][0])*(vx[j][1]-vx[0][1]) ) - ( (vx[j][0]-vx[0][0])*(vx[min][1]-vx[0][1]) );
        if( tmp &amp;lt; 0 )
          min = j;
      }/*j*/
      if( min != i ){
        tmp = vx[min][0];
        vx[min][0] = vx[i][0];
        vx[i][0] = tmp;
        
        tmp = vx[min][1];
        vx[min][1] = vx[i][1];
        vx[i][1] = tmp;
      }
    }/*i*/
    
    /*Graham Scan*/
    for(i=0; i&amp;lt;3; i++){
      g[k][i][0] = vx[i][0];
      g[k][i][1] = vx[i][1];
    }
    s = 2; /*s: current stack*/
    for(i; i&amp;lt;v; i++){
      tmp = ( (g[k][s][0]-g[k][s-1][0])*(vx[i][1]-g[k][s-1][1]) ) - ( (vx[i][0]-g[k][s-1][0])*(g[k][s][1]-g[k][s-1][1]) );
      if( tmp &amp;gt; 0 ){
        s++;
        g[k][s][0] = vx[i][0];
        g[k][s][1] = vx[i][1];
      }
      else if( tmp == 0 ){
        g[k][s][0] = vx[i][0];
        g[k][s][1] = vx[i][1];
      }
      else{
        s--;
        i--;
      }
    }
    s++;
    g[k][s][0] = g[k][0][0];
    g[k][s][1] = g[k][0][1];
    gn[k] = s;
    
  }/*while kingdom data input*/
  
  /*Missile attacks*/
  while( scanf(&amp;quot;%d %d&amp;quot;, &amp;amp;mx, &amp;amp;my) != EOF ){
    at = findaim(mx, my);
    if( at != -1 )
      attack[at] = 1;
  }/*while missile attacks input*/
  
  /*Output*/
  tot = 0.0;
  for(i=0; i&amp;lt;=k; i++)
    if( attack[i] == 1 )
      tot += findarea(i);
  printf(&amp;quot;%.2f\n&amp;quot;, tot);
  
  exit(0);
}

int findaim(int x, int y){
  int i;
  
  for(i=0; i&amp;lt;=k; i++){
    if( isinside(i, x, y) == 1 )
      return i;
  }/*i: scan through all kingdoms*/

  return -1;
}

int isinside(int kd, int x, int y){
  int i, tmp;
  
  if( y &amp;lt; g[kd][0][1] )
    return 0;
    
  for(i=0; i&amp;lt;gn[kd]; i++){
    tmp = ( ( g[kd][i+1][0]-g[kd][i][0] )*( y-g[kd][i][1] ) ) - ( ( x-g[kd][i][0] )*( g[kd][i+1][1]-g[kd][i][1] ) );
    if( tmp &amp;lt; 0 )
      return 0;
  }
  return 1;
}

float findarea(int kd){
  int i;
  float tmp, sum;
  
  sum = 0.0;
  for(i=1; i&amp;lt;=gn[kd]; i++){
    tmp = ( (g[kd][i-1][0])*(g[kd][i][1]) )-( (g[kd][i][0])*(g[kd][i-1][1]) );
    tmp /= 2;
    sum += tmp;
  }
  
  return sum;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-954135214695702083?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/954135214695702083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-109-scud-buster.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/954135214695702083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/954135214695702083'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-109-scud-buster.html' title='ACM: 109 – SCUD Buster'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6472817493260276345</id><published>2010-08-18T15:48:00.001+08:00</published><updated>2010-08-18T15:48:35.171+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 108 - Maximum Sum</title><content type='html'>&lt;p&gt;這一題是給一個二維陣列，要找出有最大和的子陣列，傳回和的值。原本想不出更好的方法，只好用brute force搜尋所有子陣列 ，但預料之內的Time Limit Exceed(UVa好厲害啊)。查了資料，才知道解決之道在於 Kadane’s Algorithm。&lt;/p&gt;  &lt;p&gt;Kadane’s Algorithm可以O(n)找到一維陣列的最大和子序列，&lt;a href="http://www.algorithmist.com/index.php/Kadane's_Algorithm" target="_blank"&gt;Algorithmist&lt;/a&gt;上的pseudo code如下：&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;Kadane's Algorithm(arr[1..n])
begin
    (max, a, b) := (-INFINITY, 0, 0)
    curr := 0
    aa := 1
    for bb := 1 to n do
        curr := curr + arr[bb]
        if curr &amp;gt; max then
            (max, a, b) := (curr, aa, bb)
        endif

        if curr &amp;lt; 0 then
            curr := 0
            aa := bb + 1
        endif
    endfor

    return (max, a, b)
end&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;即是從陣列頭開始，不斷累加陣列元素值，同時不斷更新最大值，一旦累加和&amp;lt;0，就把累加變數歸零。因為一旦是負數，下一個元素值不管是正數或負數，都只會越加越小，所以不可能會是maximum了。如此，只需要讀過一次陣列就可以找到最大和子序列，真是神奇啊！&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 100

int main(){
  int i, j, k;
  int n, t[MAX][MAX], sum, max;
  
  scanf(&amp;quot;%d&amp;quot;, &amp;amp;n);
  for(i=0; i&amp;lt;n; i++)
    for(j=0; j&amp;lt;n; j++)
      scanf(&amp;quot;%d&amp;quot;, &amp;amp;t[i][j]);
  
  /*calculate vertical sum*/
  for(i=0; i&amp;lt;n; i++){
    for(j=1; j&amp;lt;n; j++){
      t[j][i] += t[j-1][i];
    }/*j: row*/
  }/*i: column*/
  
  max = t[0][0];
  /*find max sum*/
  for(i=0; i&amp;lt;n; i++){
    for(j=i; j&amp;lt;n; j++){
      sum = 0;
      for(k=0; k&amp;lt;n; k++){
        if( i==j || i==0 )
          sum += t[j][k];
        else
          sum += ( t[j][k] - t[i-1][k] );
        
        if( sum &amp;gt; max )
          max = sum;
        else if( sum &amp;lt; 0 )
          sum = 0;
      }
    }/*j: ending row*/
  }/*i: starting row*/
  
  printf(&amp;quot;%d\n&amp;quot;, max);
  exit(0);
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6472817493260276345?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6472817493260276345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-108-maximum-sum.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6472817493260276345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6472817493260276345'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-108-maximum-sum.html' title='ACM: 108 - Maximum Sum'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7716162275941483563</id><published>2010-08-17T21:29:00.000+08:00</published><updated>2010-08-17T21:30:10.474+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM: 104 - Arbitrage</title><content type='html'>&lt;p&gt;這一題我原先使用了brute force找出所有的換匯途徑，再檢查是否獲利，但這樣會超過time limit，有效率的解法必須使用Floyd-Warshall演算法。參考了&lt;a href="http://chchwy.twgg.org/2008/12/acm-some-hint-about-uva-104.html" target="_blank"&gt;Mat所轉錄的文章&lt;/a&gt;，研究了一陣，才了解Floyd-Warshall演算法一層層找最佳中繼點，最後再重建路徑回去的方法！但想通了真覺得Floyd-Warshall很美妙呢！&lt;/p&gt;  &lt;p&gt;這題可說是找一個weighted graph從一點開始再回到一點的最短路徑，例如(0,.., 0)，先找第一個最佳中繼點(0, k1, 0)，紀錄下這個k1後，再找第二層中繼點(k1, k2, 0)，再紀錄下k2然後繼續…。最後，再從最後kn中繼點，重建回k1，便可以重建(0, k1, k2, .., kn, 0)的完整路徑了。&lt;/p&gt;  &lt;p&gt;在我的code裡面，我一找到獲利的路徑後就跳出floyd-warshall。跟這題奮鬥多天的結果是Runtime 0.044，Rank 88！開心！&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

#define MAX 20

double profit[MAX][MAX][MAX];
int n, st, path[MAX][MAX][MAX];

int fw(void);

int main(){
  int i, j, s;
  int final[MAX];
  
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;n) != EOF ){
    /*initialize profit array*/
    for(s=0; s&amp;lt;n; s++){
      for(i=0; i&amp;lt;n; i++){
        for(j=0; j&amp;lt;n; j++){
          profit[s][i][j] = 0.0;
        }/*j*/
      }/*i*/
    }/*s*/
    
    /*read rates table*/
    for(i=0; i&amp;lt;n; i++){
      for(j=0; j&amp;lt;n; j++){
        if( i==j )
          profit[0][i][j] = 1.0;
        else
          scanf(&amp;quot;%lf&amp;quot;, &amp;amp;profit[0][i][j]);
        path[0][i][j] = i;
      }
    }
    
    /*Floyd-Warshall*/
    if( (s = fw()) &amp;gt; 0 ){
      /*Re-construct path*/
      final[0] = j = st;
      i = s;
      for(i; i&amp;gt;0; i--){
        final[i] = path[i][st][j];
        j = final[i];
      }
      
      for(i=0; i&amp;lt;=s; i++){
        printf(&amp;quot;%d &amp;quot;, final[i]+1);
      }
      printf(&amp;quot;%d\n&amp;quot;, st+1);
    }
    else{
      printf(&amp;quot;no arbitrage sequence exists\n&amp;quot;);
    }
  }/*while input data*/
  
  exit(0);
}

/*Return step when arbitrage exists; Return 0 when no arbitrage exists*/
int fw(void){
  int i, j, k, p;
  int s;
  double tmp;
  
  for(s=1; s&amp;lt;n; s++){
    for(k=0; k&amp;lt;n; k++){
      for(i=0; i&amp;lt;n; i++){
        for(j=0; j&amp;lt;n; j++){
          tmp = profit[s-1][i][k] * profit[0][k][j];
          if( tmp &amp;gt; profit[s][i][j] ){
            profit[s][i][j] = tmp;
            path[s][i][j] = k;
          }
        }/*j*/
      }/*i*/
    }/*k: intermediate node*/
    
    
    /*check if arbitrage exists*/
    for(p=0; p&amp;lt;n; p++){
      if( profit[s][p][p] &amp;gt; 1.01 ){
        st = p;
        return s;
      }
    }
  }/*s: step*/
  
  return 0;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7716162275941483563?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7716162275941483563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-104-arbitrage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7716162275941483563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7716162275941483563'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm-104-arbitrage.html' title='ACM: 104 - Arbitrage'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1718144018048974936</id><published>2010-08-16T17:57:00.001+08:00</published><updated>2010-08-16T18:06:34.940+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>106 - Fermat vs. Pythagoras</title><content type='html'>&lt;p&gt;&lt;a href="http://uva.onlinejudge.org/external/1/106.html" target="_blank"&gt;106 – Fermat vs. Pythagoras&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;這一題是給一個數字N：    &lt;br /&gt;1. 找出所有小於等於N的正整數中，互質的畢式組數(如: (3, 4, 5)是一組互質的畢式組數)數量。     &lt;br /&gt;2. 找出所有小於等於N的正整數中，不能構成畢式組數(不需是互質的畢式組數)的數字數量。&lt;/p&gt;  &lt;p&gt;乍看之下只要用brute force找出所有的畢式數對即可，但由於N最大值是1,000,000，光要建立小於1,000,000的質數表就已經超過3秒鐘的Time Limit，所以一定要找其他方法。&lt;/p&gt;  &lt;p&gt;參考&lt;a href="http://www.algorithmist.com/index.php/UVa_106" target="_blank"&gt;Algorithmist&lt;/a&gt;，才發現使用畢式定理的通解，處理時間會大大的縮短。&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff8000"&gt;X&lt;/font&gt;^2 + &lt;font color="#008000"&gt;Y&lt;/font&gt;^2 = &lt;font color="#ff0080"&gt;Z&lt;/font&gt;^2     &lt;br /&gt;( &lt;font color="#ff8000"&gt;r^2 - s^2&lt;/font&gt; )^2 + ( &lt;font color="#008000"&gt;2rs&lt;/font&gt; )^2 = (&lt;font color="#ff0080"&gt; r^2 + s^2&lt;/font&gt; )^2&lt;/p&gt;  &lt;p&gt;由於Z=(r^2+s^2)，要找出 Z&amp;lt;N 即是 (r^2+s^2)&amp;lt;N，因此r, s &amp;lt; N^(1/2)，搜尋數量縮減到根號N，也就是最大1000！&lt;/p&gt;  &lt;p&gt;而互質且一奇一偶的(r, s)，可以產生所有互質的畢式組數。在乘上倍數後便可以找出其他非互質的畢式組數了。&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TIPS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;記錄數字是否為畢式組數的陣列要用char型別，int型別無法開到1,000,000&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;

int p, prime[200];

void findprime(void);
int rp(int a, int b);

int main(){
  int i, j;
  int n, r, s, rsq, ssq, rpt;
  char num[1000002]=&amp;quot;&amp;quot;;
  
  /*Find all prime numbers between 1 and 1000*/
  findprime();
  
  while( scanf(&amp;quot;%d&amp;quot;, &amp;amp;n) != EOF ){
    rpt = 0;
    
    for(r=2; (rsq = r*r)&amp;lt;n; r++){
      for(s=1; s&amp;lt;r &amp;amp;&amp;amp; (rsq+(ssq = s*s)&amp;lt;=n); s++){
        if( ((r%2 == 1) ^ (s%2 == 1)) &amp;amp;&amp;amp; (rp(r,s) == 1) ){
          rpt++;
          
          /*time the triple pair*/
          for(i=1; (i*(rsq+ssq))&amp;lt;=n; i++)
            num[ i*(rsq - ssq) ] = num[ i*(2*r*s) ] = num[ i*(rsq + ssq) ] = 1;
        }/*(r, s) pair can generate relatively prime triple*/
      }/*s*/
    }/*r*/
    
    printf(&amp;quot;%d &amp;quot;, rpt);
    j = 0;
    for(i=1; i&amp;lt;=n; i++){
      if( num[i] == 1 )
        num[i] = 0;
      else
        j++;
    }
    printf(&amp;quot;%d\n&amp;quot;, j);
  }/*while input data*/

  exit(0);
}

void findprime(void){
  int i, j, tmp[1001];
  
  for(i=2; i&amp;lt;1001; i++)
    tmp[i] = 1;
  
  p = 0;
  for(i=2; i&amp;lt;1001; i++){
    if( tmp[i] == 1 ){
      prime[p] = i;
      p++;
      
      for(j=(i+i); j&amp;lt;1001; j+=i)
        tmp[j] = 0;
    }
  }
}

int rp(int a, int b){
  int i;
  
  for(i=0; i&amp;lt;p &amp;amp;&amp;amp; prime[i]&amp;lt;a ; i++)
    if( (a % prime[i] == 0) &amp;amp;&amp;amp; (b % prime[i] == 0) )
      return 0;
  
  return 1;
}&lt;/pre&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1718144018048974936?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1718144018048974936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/106-fermat-vs-pythagoras.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1718144018048974936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1718144018048974936'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/106-fermat-vs-pythagoras.html' title='106 - Fermat vs. Pythagoras'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6769950420216356046</id><published>2010-08-16T17:12:00.000+08:00</published><updated>2010-08-16T17:13:05.065+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ACM'/><title type='text'>ACM</title><content type='html'>&lt;p&gt;從頭開始一題一題寫，目前為止11天寫了7題，很好，加油加油加油！&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6769950420216356046?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6769950420216356046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6769950420216356046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6769950420216356046'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/acm.html' title='ACM'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-2407362003878628218</id><published>2010-08-01T22:35:00.001+08:00</published><updated>2010-08-02T00:46:03.924+08:00</updated><title type='text'>石田同學</title><content type='html'>&lt;p&gt;我們這一家的石田同學，我行我素地太可愛了！冷面笑匠一流角色，但她自己卻不覺得有什麼好笑的，哈哈。以下幾集有石田：&lt;/p&gt;  &lt;p&gt;『&lt;a href="http://www.tudou.com/programs/view/EXvN3PX5-ro/" target="_blank"&gt;不可思議的孩子&lt;/a&gt;』     &lt;br /&gt;『&lt;a href="http://www.tudou.com/programs/view/BzkUb6AVUmA/" target="_blank"&gt;石田的通心粉&lt;/a&gt;』    &lt;br /&gt; &lt;a href="http://www.tudou.com/programs/view/1i_zexrzMQs/" target="_blank"&gt;『石田不說謊』&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-2407362003878628218?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/2407362003878628218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2407362003878628218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/2407362003878628218'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/08/blog-post.html' title='石田同學'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7340625441375031089</id><published>2010-06-30T21:25:00.003+08:00</published><updated>2010-06-30T21:34:09.245+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>Lion Army: Battle To Survive</title><content type='html'>&lt;p&gt;前個星期在Nat Geo Wild看了&amp;quot;Lion Army: Battle To Survive&amp;quot;(片名譯作：獅子大軍)，看了真覺得獅子好有王者之風呢！影片最讓我印象深刻的有三個地方&lt;/p&gt;  &lt;p&gt;1. 獅群狩獵原來有“陣式”的，不是看到獵物就撲出去那麼簡單。年輕獅子負責在幾個點埋伏、甚至阻擋獵物可能去路，而領頭的母獅在佈局完成後伺機發動出擊！而獵物如鹿、斑馬、長頸鹿等也不斷在留意是否有獵食者在附近，不會傻傻地等自己落入陷阱。&lt;/p&gt;  &lt;p&gt;2. 獅群是由母獅帶領幼獅及年輕的獅子組成，公獅會在離獅群一段距離的範圍內巡邏保護獅群。片中有一段由於年輕獅子狩獵經驗不足，獅群五天沒有吃東西了，那日夜晚，獅群集體發出一種悲戚的聲音。在這之後，這兩頭外圍公獅竟在夜幕中緩緩出現！兩頭公獅英姿煥發、睥睨天下般地走來，檢視獅群，原本在打鬧的年輕獅子在公獅駕臨後竟不敢再玩了！隔天公獅帶領狩獵，並擔任咬住獵物頭的重要位置，大家都有飯吃，公獅實在Man爆！&lt;/p&gt;  &lt;p&gt;3. 新生獅子太可愛了，跟母獅玩時竟是四腳朝天的！另一個驚訝在於，獅群裡的年輕母獅竟會用一隻前肢放在新生獅背上表示關心！但小獅並不領情，令我想到幼童時最不喜歡被親戚捏臉頰之類的，哈哈。&lt;/p&gt;  &lt;p&gt;Youtube上有這影片，還是High Definition的！&lt;/p&gt;  &lt;p&gt;Part 1    &lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/25kPN5s0EZw&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/25kPN5s0EZw&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Part 2    &lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/dD7W-5zPl6k&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/dD7W-5zPl6k&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Part 3    &lt;br /&gt;&lt;object width="560" height="340"&gt;&lt;param name="movie" value="http://www.youtube.com/v/CdTFqXkQTlc&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/CdTFqXkQTlc&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Part 4    &lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/lE52rxwwlss&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/lE52rxwwlss&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Part 5    &lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/TyaqP_MCKW8&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/TyaqP_MCKW8&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Part 6   &lt;br /&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/d-POmFGIVXE&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/d-POmFGIVXE&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7340625441375031089?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7340625441375031089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/lion-army-battle-to-survive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7340625441375031089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7340625441375031089'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/lion-army-battle-to-survive.html' title='Lion Army: Battle To Survive'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-879341467640320450</id><published>2010-06-05T21:27:00.004+08:00</published><updated>2010-06-30T18:25:48.443+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>周杰倫 - 好久不見</title><content type='html'>周杰倫這張新專輯《跨時代》裡，我喜歡的兩首是＜好久不見＞和＜自導自演＞，這篇先寫前者。＜好久不見＞雖然講的是要女朋友回到他身邊，但不是苦情一路的，反而唱得溫暖到甜甜的。MV是2010台北花博的推廣片，也是甜到看著不自覺露出微笑呢。曲子間中用台語分飾主角的朋友蠻有趣的，似乎這張專輯加入了比較多台語。&lt;br /&gt;
&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Ul26b4fwJpw&amp;hl=en_US&amp;fs=1&amp;"&gt;

&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;

&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;

&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/Ul26b4fwJpw&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
好久不見&lt;br /&gt;
作詞：周杰倫
  &lt;br /&gt;
作曲：周杰倫

  &lt;br /&gt;
編曲：蔡庭貴 &lt;br /&gt;
好久不見 你還好嗎 你的小狗 長大了嗎
  &lt;br /&gt;
我的圍巾 還圍著嗎 我的相片 都丟了吧

  &lt;br /&gt;
我剪不到後面頭髮 這個藉口還不錯吧(哎喲不錯)

  &lt;br /&gt;
一把剪刀一堆廢話 還不是想求求你回來吧 &lt;br /&gt;
麥擱一個人咧生氣 乎伊煩惱 乎伊操心
  &lt;br /&gt;
雖然不關我ㄟ代誌 誰叫他是我ㄟ兄弟 耶

  &lt;br /&gt;
攏這麼久就唰唰去 想想秋天就馬過去 耶

  &lt;br /&gt;
冬天來臨他會怕冷 你不回來甘講要我抱伊 按呢甘好 &lt;br /&gt;
是我不好 我沒有緊緊抱住你 你說淚留著很危險
  &lt;br /&gt;
如果等雨一起(等雨一起) 流下不讓同情發現 &lt;br /&gt;
我對天空這個那個流星 大喊後會不會有奇蹟
  &lt;br /&gt;
就算做朋友也沒關係 為你改變了自己都不認識自己

  &lt;br /&gt;
不是我跑去了整形 只是我拿出真心

  &lt;br /&gt;
開一瓶這個那個香檳 去我的Mr.J餐廳

  &lt;br /&gt;
點蠟燭順便吃個甜品 慶祝你打死不連絡的毅力

  &lt;br /&gt;
冷戰早已經不流行 趕快回來到 我身邊&lt;br /&gt;
歌詞轉載自：&lt;a href="http://mojim.com/twy100951x29x5.htm" target="_blank"&gt;Mojim歌詞網&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-879341467640320450?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/879341467640320450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/879341467640320450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/879341467640320450'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/blog-post.html' title='周杰倫 - 好久不見'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-6057868654010667491</id><published>2010-06-05T20:45:00.003+08:00</published><updated>2010-06-05T20:46:48.525+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><title type='text'>list: 2010年聽的專輯</title><content type='html'>&lt;div align="right"&gt;
last update: 5 Jun 2010&lt;/div&gt;
&lt;table border="0" cellpadding="2" cellspacing="0" style="width: 413px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;&lt;strong&gt;Jun&lt;/strong&gt;&lt;/td&gt;&lt;td valign="top" width="332"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊＊＊+&lt;/td&gt;&lt;td valign="top" width="332"&gt;周杰倫 - &lt;em&gt;跨時代&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;&lt;/td&gt;&lt;td valign="top" width="332"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;&lt;strong&gt;Feb&lt;/strong&gt;&lt;/td&gt;&lt;td valign="top" width="332"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊＊＊＊&lt;/td&gt;&lt;td valign="top" width="332"&gt;World End’s Girlfriend – &lt;em&gt;Hurt Break Wonderland&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊&lt;/td&gt;&lt;td valign="top" width="332"&gt;楊丞琳 - &lt;em&gt;雨愛&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊+&lt;/td&gt;&lt;td valign="top" width="332"&gt;謝安琪 - &lt;em&gt;Binary&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;&lt;/td&gt;&lt;td valign="top" width="332"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;&lt;strong&gt;Jan&lt;/strong&gt;&lt;/td&gt;&lt;td valign="top" width="332"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊＊＊&lt;/td&gt;&lt;td valign="top" width="332"&gt;徐佳瑩 – &lt;em&gt;LaLa首張創作專輯&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊＊&lt;/td&gt;&lt;td valign="top" width="332"&gt;中島美嘉 – &lt;em&gt;No More Rules&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top" width="79"&gt;＊＊＊&lt;/td&gt;&lt;td valign="top" width="332"&gt;中島美嘉 – &lt;em&gt;Over Load&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-6057868654010667491?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/6057868654010667491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/list-2010_05.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6057868654010667491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/6057868654010667491'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/list-2010_05.html' title='list: 2010年聽的專輯'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-5337805562840888169</id><published>2010-06-05T03:17:00.000+08:00</published><updated>2010-06-05T06:01:01.809+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>Game, set, match, Soderling</title><content type='html'>&lt;table border="0" cellspacing="2" cellpadding="2"&gt;&lt;tr&gt;&lt;td&gt;&lt;a title="4 Jun by tagtraum house, on Flickr" href="http://www.flickr.com/photos/tagtraumhouse/4669360959/"&gt;&lt;img src="http://farm5.static.flickr.com/4044/4669360959_f1e28b436d.jpg" alt="4 Jun" width="250" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a title="4 Jun by tagtraum house, on Flickr" href="http://www.flickr.com/photos/tagtraumhouse/4669985292/"&gt;&lt;img src="http://farm5.static.flickr.com/4039/4669985292_11c8372dc4.jpg" alt="4 Jun" width="250" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;img src="http://farm5.static.flickr.com/4014/4669985060_7f10b02653.jpg" alt="4 Jun" width="250" /&gt;&lt;/td&gt;&lt;td&gt;&lt;a title="4 Jun by tagtraum house, on Flickr" href="http://www.flickr.com/photos/tagtraumhouse/4669985388/"&gt;&lt;img src="http://farm5.static.flickr.com/4021/4669985388_e6a3bdecd3.jpg" alt="4 Jun" width="250" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Soderling played a tough match against No.15 seed T. Berdych at Semifinal today. The match go into the 5th set. And not before the last 3 games did Sod seem to have an edge. After 3 hours and 26 mins from the start of the match, the first and the only match point finally came for Sod. Congrats Sod for achieving his second ticket to Roland Garros finals.&lt;/p&gt;&lt;p&gt;Further: &lt;a href="http://www.rolandgarros.com/en_FR/news/match_reports/2010-06-04/201006041275655232018.html" target="_blank"&gt;As it happened: Soderling v Berdych&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-5337805562840888169?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/5337805562840888169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/game-set-match-soderling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5337805562840888169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/5337805562840888169'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/game-set-match-soderling.html' title='Game, set, match, Soderling'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm5.static.flickr.com/4044/4669360959_f1e28b436d_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1048290108252695363</id><published>2010-06-02T01:53:00.000+08:00</published><updated>2010-06-05T05:11:16.314+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>Le sod</title><content type='html'>&lt;p&gt;&lt;a title="1 Jun by tagtraum house, on Flickr" href="http://www.flickr.com/photos/tagtraumhouse/4669383963/"&gt;&lt;img src="http://farm2.static.flickr.com/1292/4669383963_da1ac574b6.jpg" alt="1 Jun" width="400" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Robin Soderling defeated No.1 ranking Roger Federer at 1 June 3-6, 6-3, 7-5, 6-4, ending his 12-match loosing streak to Fed. It was a good match. Sod played aggressively yet cautious of any faults. In the 2.5 hours match, Sod performed 14 aces, 49 winners, 6 double faults versus Fed's 12 aces, 40 winners, 2 double faults. Comparing to last year, Soderling is improving amazingly fast I think. Keep going, le sod!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Further: &lt;a href="http://www.atpworldtour.com/News/Tennis/2010/05/Roland-Garros/Roland-Garros-Tuesday2-Soderling-Stuns-Federer.aspx" target="_blank"&gt;Soderling Stuns Federer For Semi-final Berth; Battle For No.1 Intensifies&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The copyright of above image belongs to Roland Garros&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1048290108252695363?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1048290108252695363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/le-sod.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1048290108252695363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1048290108252695363'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/06/le-sod.html' title='Le sod'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm2.static.flickr.com/1292/4669383963_da1ac574b6_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7769750178231702124</id><published>2010-05-25T09:32:00.000+08:00</published><updated>2010-06-05T05:11:16.315+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>cute!!!</title><content type='html'>&lt;p&gt;Learned the &lt;em&gt;&lt;a href="http://en.wikipedia.org/wiki/Verreaux's_Sifaka" target="_blank"&gt;Verreaux's sifaka&lt;/a&gt;&lt;/em&gt; from this month's scientific american. It's a kind of sifaka (狐猴) living in Madagascar. Can't believe there's such a cute and interesting creature in the world!&lt;/p&gt;
&lt;p&gt;
&lt;table border="0" cellspacing="4" cellpadding="4"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p style="text-align: center;"&gt;&lt;img style="border: 0;" title="200569957-001.jpg" src="http://pic.pimg.tw/tagtraum/4bfb9c8051de8.jpg" border="0" alt="200569957-001.jpg" height="300" /&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img title="Sifaka&amp;amp;Baby_tm.jpg" src="http://pic.pimg.tw/tagtraum/4bfb9cd44c37c.jpg" border="0" alt="Sifaka&amp;amp;Baby_tm.jpg" /&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;&lt;img style="border: 0;" title="80760965.Zhr6KEIE.jpg" src="http://pic.pimg.tw/tagtraum/4bfb9de0e3e51.jpg" border="0" alt="80760965.Zhr6KEIE.jpg" width="400" /&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7769750178231702124?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7769750178231702124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/05/cute.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7769750178231702124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7769750178231702124'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/05/cute.html' title='cute!!!'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-4749062476493092921</id><published>2010-05-19T07:37:00.000+08:00</published><updated>2010-06-05T05:11:16.317+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='流到香江'/><title type='text'>Now</title><content type='html'>&lt;p&gt;It's raining and thundering in Hong Kong now. Although its 3 pm, the outside just dark as 3 am.&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-4749062476493092921?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/4749062476493092921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/05/now.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4749062476493092921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4749062476493092921'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/05/now.html' title='Now'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-4678920804332166031</id><published>2010-03-29T04:25:00.000+08:00</published><updated>2010-06-05T05:11:16.318+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>林峰 - 忘記傷害</title><content type='html'>&lt;p&gt;律政新人王的主題曲，初初聽到時並不覺得怎樣，但就越聽越耐聽，我想林夕的詞功不可沒。&lt;/p&gt;
&lt;p&gt;
&lt;object width="560" height="340"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/UlLj6ijlyRY&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="560" height="340" src="http://www.youtube.com/v/UlLj6ijlyRY&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;忘記傷害 - 林峰(「律政新人王」主題曲)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;曲：馮翰銘　詞：林夕&amp;nbsp;&lt;/p&gt;
&lt;p&gt;當　這感覺未發生　不知道你光臨&lt;br /&gt;我大概還可繼續散心&lt;/p&gt;
&lt;p&gt;無奈我的心　不經意著了燈&lt;br /&gt;為得不到的吸引　令我不糾纏亦不忍&lt;/p&gt;
&lt;p&gt;當　他手放在你身&lt;br /&gt;才想到我是好友永遠沒權利去傷感&amp;nbsp;&lt;/p&gt;
&lt;p&gt;＃忘記受過傷害 　施捨最假的愛&lt;br /&gt;也會令我肯相信這段感情避不開&lt;/p&gt;
&lt;p&gt;忘記如何忍耐&lt;br /&gt;但期待一夜之間醒過來&lt;br /&gt;我和你便已如戀人熱愛＃&lt;/p&gt;
&lt;p&gt;想　想一世待你好　不需要有出路&lt;br /&gt;那是我唯一快樂&lt;/p&gt;
&lt;p&gt;其實期望未算高　不擁抱便跌倒&lt;br /&gt;付出的都不苦惱　被愛的當然未知道&lt;/p&gt;
&lt;p&gt;好　即使我未夠好&amp;nbsp;連哭一聲都不配你便提示我怎做&lt;/p&gt;
&lt;p&gt;ｒｅｐｅａｔ　＃&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-4678920804332166031?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/4678920804332166031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4678920804332166031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4678920804332166031'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/blog-post.html' title='林峰 - 忘記傷害'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1536098809034691264</id><published>2010-03-29T01:17:00.000+08:00</published><updated>2010-06-05T05:11:16.319+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>My Song Is Love Unknown by Wells Cathedral Choir</title><content type='html'>&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/Cjo-JiwyVAE&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/Cjo-JiwyVAE&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;My song is love unknown,&lt;br /&gt;My Saviour&amp;rsquo;s love to me;&lt;br /&gt;Love to the loveless shown,&lt;br /&gt;That they might lovely be.&lt;br /&gt;O who am I, that for my sake&lt;br /&gt;My Lord should take frail flesh and die?&lt;/p&gt;
&lt;p&gt;He came from His blest throne&lt;br /&gt;Salvation to bestow;&lt;br /&gt;But men made strange, and none&lt;br /&gt;The longed-for Christ would know:&lt;br /&gt;But O! my Friend, my Friend indeed,&lt;br /&gt;Who at my need His life did spend.&lt;/p&gt;
&lt;p&gt;Sometimes they strew His way,&lt;br /&gt;And His sweet praises sing;&lt;br /&gt;Resounding all the day&lt;br /&gt;Hosannas to their King:&lt;br /&gt;Then &amp;ldquo;Crucify!&amp;rdquo; is all their breath,&lt;br /&gt;And for His death they thirst and cry.&lt;/p&gt;
&lt;p&gt;Why, what hath my Lord done?&lt;br /&gt;What makes this rage and spite?&lt;br /&gt;He made the lame to run,&lt;br /&gt;He gave the blind their sight,&lt;br /&gt;Sweet injuries! Yet they at these&lt;br /&gt;Themselves displease, and &amp;rsquo;gainst Him rise.&lt;/p&gt;
&lt;p&gt;They rise and needs will have&lt;br /&gt;My dear Lord made away;&lt;br /&gt;A murderer they save,&lt;br /&gt;The Prince of life they slay,&lt;br /&gt;Yet cheerful He to suffering goes,&lt;br /&gt;That He His foes from thence might free.&lt;/p&gt;
&lt;p&gt;In life, no house, no home&lt;br /&gt;My Lord on earth might have;&lt;br /&gt;In death no friendly tomb&lt;br /&gt;But what a stranger gave.&lt;br /&gt;What may I say? Heav&amp;rsquo;n was His home;&lt;br /&gt;But mine the tomb wherein He lay.&lt;/p&gt;
&lt;p&gt;Here might I stay and sing,&lt;br /&gt;No story so divine;&lt;br /&gt;Never was love, dear King!&lt;br /&gt;Never was grief like Thine.&lt;br /&gt;This is my Friend, in Whose sweet praise&lt;br /&gt;I all my days could gladly spend.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Lyric source: &lt;a href="http://en.wikipedia.org/wiki/My_Song_Is_Love_Unknown" target="_blank"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1536098809034691264?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1536098809034691264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/my-song-is-love-unknown-by-wells.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1536098809034691264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1536098809034691264'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/my-song-is-love-unknown-by-wells.html' title='My Song Is Love Unknown by Wells Cathedral Choir'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-543352850893775565</id><published>2010-03-26T06:36:00.000+08:00</published><updated>2010-06-05T05:11:16.321+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>6分の1の夢旅人（「水曜どうでしょう」主題曲）</title><content type='html'>&lt;p&gt;
&lt;object width="480" height="385"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/uoNKJhimRrQ&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/uoNKJhimRrQ&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;曲名：6分の1の夢旅人&lt;br /&gt;演唱：樋口了一&lt;/p&gt;
&lt;p&gt;【日文歌詞】&lt;/p&gt;
&lt;p&gt;まわるよ、まわる、地球はまわる&lt;br /&gt;何もなかった頃から同じように&lt;br /&gt;いつもいつでも、飛び出せるように&lt;br /&gt;ダイスのように転がっていたいから&lt;/p&gt;
&lt;p&gt;泣きたくなるような時も&lt;br /&gt;君に逢いに行きたくなっても&lt;br /&gt;強がるだけ&lt;br /&gt;今は何もわからない&lt;/p&gt;
&lt;p&gt;世界中を僕らの涙で埋めつくして&lt;br /&gt;やりきれないこんな思いが今日の雨を降らせても&lt;br /&gt;新しいこの朝がいつものように始まる&lt;br /&gt;そんな風に そんな風に&lt;br /&gt;僕は生きたいんだ、生きていきたいんだ&lt;/p&gt;
&lt;p&gt;一人きりではできないことも&lt;br /&gt;タフな笑顔の仲間となら乗り切れる&lt;br /&gt;たどり着いたらそこはスタート&lt;br /&gt;ゴールを決める余裕なんて今はない&lt;/p&gt;
&lt;p&gt;誰かを愛することが&lt;br /&gt;何かを信じ続けることが&lt;br /&gt;何より今、この体を支えてくれるんだ&lt;/p&gt;
&lt;p&gt;世界中を僕らの涙で埋めつくして&lt;br /&gt;疲れきった足元から全て凍り尽くしても&lt;br /&gt;いつの日にかきっと南風が歌い出す&lt;br /&gt;そんな風に&amp;nbsp;そんな風に&lt;br /&gt;僕は笑いたいんだ 笑っていたいんだ&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;【中文翻譯】&lt;/p&gt;
&lt;p&gt;環繞、環繞、環繞地球&lt;br /&gt;就像什麼都沒發生過&lt;br /&gt;一直一直、像是飛出去一樣&lt;br /&gt;因為我想要像骰子一樣滾動&lt;/p&gt;
&lt;p&gt;哭泣的時候&lt;br /&gt;害怕走向你的時候&lt;br /&gt;只需要勇敢一點&lt;br /&gt;現在我什麼也不知道&lt;/p&gt;
&lt;p&gt;讓這個世界充滿我流淚的痕跡&lt;br /&gt;即使今天的大雨讓我覺得失去力量&lt;br /&gt;還是要像新的早晨般重新開始&lt;br /&gt;就是這樣 就是這樣&lt;br /&gt;我 想要生活下去 想要生活下去&amp;nbsp;&lt;/p&gt;
&lt;p&gt;獨自一個人做不到的事&lt;br /&gt;是在同伴露出堅強微笑時 跟他分享心情&lt;br /&gt;從遍嘗人生百味的地方啟程&lt;br /&gt;而終點現在沒有多餘的時間決定&lt;/p&gt;
&lt;p&gt;相信我能愛什麼人&lt;br /&gt;帶著我所相信的什麼 繼續走下去&lt;br /&gt;最重要的是 我願意站在我自己這邊&lt;/p&gt;
&lt;p&gt;讓這個世界充滿我流淚的痕跡&lt;br /&gt;即使疲憊的雙腳又在嚴寒中凍僵 透心寒意讓我不知所措&lt;br /&gt;溫暖白日一定會在什麼時候來到 南風之歌便會飄揚&lt;br /&gt;就是這樣 就是這樣&lt;br /&gt;我 想要笑出來 想要笑出來&amp;nbsp;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-543352850893775565?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/543352850893775565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/61.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/543352850893775565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/543352850893775565'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/61.html' title='6分の1の夢旅人（「水曜どうでしょう」主題曲）'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7810672229895849592</id><published>2010-03-17T11:40:00.000+08:00</published><updated>2010-06-05T05:11:16.323+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><title type='text'>list: 口袋歌單</title><content type='html'>&lt;p&gt;需要力量的時候...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;table border="0" cellspacing="4" cellpadding="4"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;咖啡王子一號店 - &lt;a href="http://www.youtube.com/watch?v=NQYh0mRdZO4" target="_blank"&gt;La la la, It's Love !&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Humming Urban Stereo (feat.Yozoh) - Coffee Hanjan Eottae?&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Casker - Mocha&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;哆啦A夢 -&amp;nbsp;&lt;a style="text-decoration: none;" href="http://tagtraum.pixnet.net/blog/post/26992178" target="_blank"&gt;夢をかなえてドラえもん&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;太鼓達人wii -&amp;nbsp;&lt;a href="http://tagtraum.pixnet.net/blog/post/26936474" target="_blank"&gt;どん子のファーストデート&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;中島美嘉 -&amp;nbsp;&lt;a href="http://tagtraum.pixnet.net/blog/post/30414964" target="_blank"&gt;雪之華&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;黃靖倫 - 傻裡傻氣&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;陳嘉唯 - &lt;a href="http://tagtraum.pixnet.net/blog/post/30417597" target="_blank"&gt;幸福導航&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;張韶涵 - Journey&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;張韶涵 - 手心的太陽&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;張韶涵 - 遺失的美好&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;徐佳瑩 -&amp;nbsp;&lt;a href="http://www.youtube.com/watch?v=PR_okWd7a2Y" target="_blank"&gt;出口&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7810672229895849592?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7810672229895849592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7810672229895849592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7810672229895849592'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/03/list.html' title='list: 口袋歌單'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-4542680318766814458</id><published>2010-02-28T04:31:00.000+08:00</published><updated>2010-06-05T05:11:16.329+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>City Quiz</title><content type='html'>&lt;p&gt;Taken "what's your city" quiz from &lt;a href="http://www.blogthings.com/whatsyourcityquiz/" target="_blank"&gt;here&lt;/a&gt; and it said that the city for me is&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Buenos_Aires" target="_blank"&gt;Buenos Aires&lt;/a&gt;! After playing the game &lt;em&gt;Chocolatier 2&lt;/em&gt;, Buenos Aires is linked with Oranges in my mind...&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Your City is Buenos Aires&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You are cultured, sophisticated, and quite old fashioned. You believe traditions are important, but you are still quite vibrant.&lt;br /&gt;People don't know you well at all, and if they do, they totally misunderstand what you are all about.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You are more interesting and more intelligent than anyone gives you credit for. You are a bit of a hidden treasure.&lt;br /&gt;You are creative, ambitious, beautiful, and fun. You may have a rough past, but you are always getting better.&lt;/em&gt;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-4542680318766814458?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/4542680318766814458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/city-quiz.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4542680318766814458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/4542680318766814458'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/city-quiz.html' title='City Quiz'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1260968604120130894</id><published>2010-02-15T05:57:00.000+08:00</published><updated>2010-06-05T05:11:16.330+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>徐佳瑩 - P.S我愛你</title><content type='html'>&lt;p&gt;一年前的節目了，今天才在youtube上偶然聽到，真是很喜歡lala溫暖的聲音。&lt;/p&gt;
&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/XzBQnu3rCGo&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/XzBQnu3rCGo&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;P.S.我愛你 (原唱：A-Lin)&lt;/p&gt;
&lt;p&gt;詞：鄔裕康 曲：劉勇志&lt;/p&gt;
&lt;p&gt;我想要成為你的眼&lt;br /&gt;把最美的風景 收進你的心中&lt;/p&gt;
&lt;p&gt;我想要成為你的手&lt;br /&gt;好讓我 從現在到以後&lt;br /&gt;佔有你溫柔 一刻不放過&lt;/p&gt;
&lt;p&gt;恨不得把明天沒收&lt;br /&gt;讓你永遠不會變動&lt;br /&gt;專注的愛著我&lt;/p&gt;
&lt;p&gt;我愛你沒有保留&lt;br /&gt;我愛你就到最後&lt;br /&gt;有些人值得等候&lt;br /&gt;有些悲傷值得忍受&lt;/p&gt;
&lt;p&gt;我愛你不是衝動&lt;br /&gt;生命盡頭反正一場空&lt;br /&gt;只要你記得 我們那麼愛過&lt;/p&gt;
&lt;p&gt;我要替你收集笑容&lt;br /&gt;怕未來 快樂變得貴重&lt;br /&gt;要是少了我 你有多寂寞&lt;/p&gt;
&lt;p&gt;恨不得把明天沒收&lt;br /&gt;讓你永遠不會變動&lt;br /&gt;專注的愛著我&lt;/p&gt;
&lt;p&gt;我愛你沒有保留&lt;br /&gt;我愛你就到最後&lt;br /&gt;有些人值得等候&lt;br /&gt;有些悲傷值得忍受&lt;/p&gt;
&lt;p&gt;我愛你不是衝動&lt;br /&gt;生命盡頭反正一場空&lt;br /&gt;只要你記得 我們那麼愛過&lt;/p&gt;
&lt;p&gt;太陽不會放棄天空&lt;br /&gt;哪怕你不再屬於我&lt;br /&gt;我會在不同的窗口 給你擁抱&lt;/p&gt;
&lt;p&gt;我愛你沒有保留&lt;br /&gt;我愛你就到最後&lt;br /&gt;有些人值得等候&lt;br /&gt;有些悲傷值得忍受&lt;/p&gt;
&lt;p&gt;我愛你不是衝動&lt;br /&gt;生命盡頭反正一場空&lt;br /&gt;只要你記得 我們那麼愛過&lt;/p&gt;
&lt;p&gt;我忘不掉 你第一次吻我&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;歌詞轉載自：&lt;a href="http://mojim.com/twy104821x3x4.htm" target="_blank"&gt;Mojim&lt;/a&gt;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1260968604120130894?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1260968604120130894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/ps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1260968604120130894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1260968604120130894'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/ps.html' title='徐佳瑩 - P.S我愛你'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1869542819427864347</id><published>2010-02-15T05:30:00.000+08:00</published><updated>2010-06-05T05:11:16.332+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>陳嘉唯 - 幸福導航</title><content type='html'>&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/hbBwbufWE6w&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/hbBwbufWE6w&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;作詞：徐世珍&lt;br /&gt;作曲：梁偉豐&lt;br /&gt;編曲：洪信傑&amp;nbsp;&lt;br /&gt;製作：薛忠銘&lt;/p&gt;
&lt;p&gt;＊天空是灰色的 可是有陽光&lt;br /&gt;　幸福是一定的 很遠又怎樣&lt;br /&gt;　快樂忘了出場 天使折了翅膀&lt;br /&gt;　我還是要希望&lt;/p&gt;
&lt;p&gt;　眼淚是溫熱的 跟擁抱一樣&lt;br /&gt;　我不會放棄的 雖然會受傷&lt;br /&gt;　通往你的路上 不會隨風飄蕩&lt;br /&gt;　想你我的心 就有重量＊&lt;/p&gt;
&lt;p&gt;＃我跟著幸福導航奔向有你的地方&lt;br /&gt;　不管距離夢想起起伏伏多漫長&amp;nbsp;&lt;br /&gt;　當時間逼著我害怕　我卻偏偏不害怕&lt;br /&gt;　無路可退就會堅強&lt;/p&gt;
&lt;p&gt;　放手讓幸福導航忘了所有的悲傷&lt;br /&gt;　因為奇蹟會是堅持的人的獎賞&lt;br /&gt;　當我終於學會了飛　能夠擁有全世界&lt;br /&gt;　我想要的只有一樣　在你身旁＃&lt;/p&gt;
&lt;p&gt;REPEAT＊＃＃&lt;/p&gt;
&lt;p&gt;時時刻刻　在你身旁&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;歌詞轉載自：&lt;a href="http://mojim.com/twy104253x2x3.htm" target="_blank"&gt;Mojim&lt;/a&gt;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1869542819427864347?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1869542819427864347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/blog-post_14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1869542819427864347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1869542819427864347'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/blog-post_14.html' title='陳嘉唯 - 幸福導航'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-7555287426231560294</id><published>2010-02-15T01:17:00.000+08:00</published><updated>2010-06-05T05:11:16.333+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='路上的風景'/><title type='text'>J. P. Chenet Colombard-Chardonnay</title><content type='html'>&lt;p&gt;&lt;img src="http://lh5.ggpht.com/_GF1-Pb0l-WE/S3bBSXMpfDI/AAAAAAAAEI0/IeilXmV4GzA/s288/DSC04015.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;First time for white wine. Nice color and scent, green apple flavor, a bit salty. Good balance of sweet and sour.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;More: &lt;a href="http://sites.google.com/a/liondistributors.com/www/j.p.chenet" target="_blank"&gt;Lion Distributors&lt;/a&gt;, &lt;a href="http://www.winebeersupermarket.com/voir_3263286346683.html" target="_blank"&gt;WBS&lt;/a&gt;, &lt;a href="http://www.snooth.com/wine/j-p-chenet-chardonnay/" target="_blank"&gt;snooth&lt;/a&gt;&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-7555287426231560294?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/7555287426231560294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/j-p-chenet-colombard-chardonnay.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7555287426231560294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/7555287426231560294'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/j-p-chenet-colombard-chardonnay.html' title='J. P. Chenet Colombard-Chardonnay'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_GF1-Pb0l-WE/S3bBSXMpfDI/AAAAAAAAEI0/IeilXmV4GzA/s72-c/DSC04015.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1378752798489870282</id><published>2010-02-14T09:51:00.000+08:00</published><updated>2010-06-05T05:11:16.334+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='燈'/><title type='text'>中島美嘉 - 雪の華(雪之華)</title><content type='html'>&lt;p&gt;Beautiful voice, beautiful lyrics. Heart-braking and brave.&lt;/p&gt;
&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/vLBSZJ1PqlI&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/vLBSZJ1PqlI&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&amp;nbsp;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;中島美嘉 - 雪の華&lt;/p&gt;
&lt;p&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;のびた人陰(かげ)を　舗道に並べ&lt;br /&gt;夕闇のなかをキミと歩いてる&lt;br /&gt;手を繋いでいつまでもずっと&lt;br /&gt;そばにいれたなら泣けちゃうくらい&lt;br /&gt;&lt;br /&gt;風が冷たくなって&lt;br /&gt;冬の匂いがした&lt;br /&gt;そろそろこの街に&lt;br /&gt;キミと近付ける季節がくる&lt;br /&gt;&lt;br /&gt;今年　最初の雪の華を　２人寄り添って&lt;br /&gt;眺めているこの時間(とき)に&lt;br /&gt;シアワセがあふれだす&lt;br /&gt;甘えとか弱さじゃない&lt;br /&gt;ただ　キミを愛してる　心からそう思った&lt;br /&gt;&lt;br /&gt;キミがいると どんなことでも&lt;br /&gt;乗りきれるような気持ちになってる&lt;br /&gt;こんな日々がいつまでもきっと　続いてくことを祈っているよ&lt;br /&gt;&lt;br /&gt;風が窓を揺らした　夜は揺り起こして&lt;br /&gt;どんな悲しいことも　ボクが笑顔へと変えてあげる&lt;br /&gt;&lt;br /&gt;舞い落ちてきた雪の華が　窓の外ずっと&lt;br /&gt;降りやむことを知らずに　ボクらの街を染める&lt;br /&gt;誰かのために何かを　したいと思えるのが　愛ということを知った&lt;br /&gt;&lt;br /&gt;もし　キミを失ったとしたなら　星になってキミを照らすだろう&lt;br /&gt;笑顔も　涙に濡れてる夜も　いつもいつでもそばにいるよ&lt;br /&gt;&lt;br /&gt;今年　最初の雪の華を　２人寄り添って&lt;br /&gt;眺めているこの時間(とき)　シアワセがあふれだす&lt;br /&gt;甘えとか弱さじゃない　ただ　キミとずっと&lt;br /&gt;このまま一緒にいたい　素直にそう思える&lt;br /&gt;&lt;br /&gt;この街に降り積もってく　真っ白な雪の華&lt;br /&gt;２人の胸にそっと想い出を描くよ&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;不斷延伸的影子 在紅磚道上並列&amp;nbsp;&lt;br /&gt;在深夜與你並肩走著&amp;nbsp;&lt;br /&gt;永遠緊緊牽著手 只要能在你身旁&amp;nbsp;&lt;br /&gt;我就感動得快要哭泣&amp;nbsp;&lt;br /&gt;&lt;br /&gt;風兒變得寒冷 有了冬天的味道&amp;nbsp;&lt;br /&gt;這條街也即將到了 能和你接近的季節來臨&amp;nbsp;&lt;br /&gt;&lt;br /&gt;今年 最初的雪花 向我倆靠近&amp;nbsp;&lt;br /&gt;在眺望著的這個時間裡&amp;nbsp;&lt;br /&gt;充滿了幸福的喜悅 沒有撒嬌和脆弱&amp;nbsp;&lt;br /&gt;只是 愛你 打從心底愛你&amp;nbsp;&lt;br /&gt;&lt;br /&gt;只要有你在 無論發生什麼&amp;nbsp;&lt;br /&gt;都會有可以克服的心情&amp;nbsp;&lt;br /&gt;我祈禱著 這樣的日子一定會直到永遠&amp;nbsp;&lt;br /&gt;&lt;br /&gt;風兒吹得窗搖 把夜晚搖醒&amp;nbsp;&lt;br /&gt;無論多麼悲傷的事 我用笑容為你改變&amp;nbsp;&lt;br /&gt;&lt;br /&gt;雪花飛舞飄落 在窗外一定&amp;nbsp;&lt;br /&gt;不知何時雪已停 把我們的街道染色&amp;nbsp;&lt;br /&gt;想為某人做些什麼事 原來 這就是愛&amp;nbsp;&lt;br /&gt;&lt;br /&gt;如果 我失去了你 我會變成星星照耀你&amp;nbsp;&lt;br /&gt;微笑 或被淚水沾濕的夜晚 我會永遠在你身旁&amp;nbsp;&lt;br /&gt;&lt;br /&gt;今年 最初的雪花 向我倆靠近&amp;nbsp;&lt;br /&gt;再眺望著的這個時間裡 充滿了幸福的喜悅&amp;nbsp;&lt;br /&gt;沒有撒嬌和脆弱 只是 想永遠地&amp;nbsp;&lt;br /&gt;就這麼一直一起 我真心地這麼想&amp;nbsp;&lt;br /&gt;&lt;br /&gt;在這條街上堆積的 純白雪花&amp;nbsp;&lt;br /&gt;悄悄地在我倆胸口畫上回憶&amp;nbsp;&lt;br /&gt;從今而後也要永遠和你在一起&lt;/p&gt;
&lt;p&gt;（歌詞轉錄自：&lt;a href="http://andre170300.pixnet.net/blog/post/8533579" target="_blank"&gt;狂人夢囈&lt;/a&gt;）&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hayley Westenra (海莉) English version:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/ZKGkjiN1e0A&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/ZKGkjiN1e0A&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;Together hand in hand we walked through evening gloom&lt;br /&gt;Long shadows on the pavement, cast from the sunset sky&lt;br /&gt;If only this would last until the end of time&lt;br /&gt;And if this is forever I swear that I could cry&lt;br /&gt;&lt;br /&gt;The northern wind starts to blow&lt;br /&gt;And the smell of winter&amp;rsquo;s in the air&lt;br /&gt;As we take each step upon the ground&lt;br /&gt;The season of love grows near&lt;br /&gt;&lt;br /&gt;We could share the very first snowflowers of the year&lt;br /&gt;In your arms where I belong&lt;br /&gt;Watch as the city turns from grey to white&lt;br /&gt;The day turns into night&lt;br /&gt;Love that floats like wayward clouds, that&amp;rsquo;s not what we&amp;rsquo;re about&lt;br /&gt;Sure and strong is my love for you&lt;br /&gt;And it comes from the bottom of my heart&lt;br /&gt;&lt;br /&gt;With you by my side, to catch me when I fall&lt;br /&gt;I can cast my fears aside; feel twice as tall&lt;br /&gt;If only this would last, this smile upon my face&lt;br /&gt;And if this is forever, you&amp;rsquo;re my saving grace&lt;br /&gt;&lt;br /&gt;The nights were so cold without you&lt;br /&gt;And the days were always short on light&lt;br /&gt;Now a fire&amp;rsquo;s warming me through&lt;br /&gt;And suddenly this upturned world is feeling right&lt;br /&gt;Yuki no Hana (Snow Flower - English Version) lyrics on&amp;nbsp;&lt;br /&gt;&lt;br /&gt;We could share the very first snowflowers of the year&lt;br /&gt;In your arms where I belong&lt;br /&gt;Watch as the city turns from grey to white&lt;br /&gt;The day turns into night&lt;br /&gt;Love that floats like wayward clouds, that&amp;rsquo;s not what we&amp;rsquo;re about&lt;br /&gt;Sure and strong is my love for you&lt;br /&gt;And it comes from the bottom of my heart&lt;br /&gt;&lt;br /&gt;If there comes a time when you have lost your way&lt;br /&gt;I&amp;rsquo;ll turn myself into a star to guide you through&lt;br /&gt;If ever you find tears upon your face&lt;br /&gt;I will be there, always be there for you&lt;br /&gt;&lt;br /&gt;We could share the very first snowflowers of the year&lt;br /&gt;In your arms where I belong&lt;br /&gt;Watch as the city turns from grey to white&lt;br /&gt;The day turns into night&lt;br /&gt;Love that floats like wayward clouds, that&amp;rsquo;s not what we&amp;rsquo;re about&lt;br /&gt;Sure and strong is my love for you&lt;br /&gt;The city turns from grey to white&lt;br /&gt;The day turns into night&lt;br /&gt;&lt;br /&gt;We could share the very first snowflowers of the year&lt;br /&gt;In your arms where I belong&lt;br /&gt;&lt;br /&gt;Cold winds from the North blow&lt;br /&gt;The sky casts its last glow&lt;br /&gt;But you and I are standing strong&lt;/p&gt;
&lt;p&gt;（歌詞轉錄自：&lt;a href="http://music.yeucahat.com/song/English/41662-Yuki-no-Hana~Hayley-Westenra.html" target="_blank"&gt;yeucahat&lt;/a&gt;）&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;國語版：蔡淳佳《對不起，我愛你》&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
&lt;object width="320" height="265"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/kjzs9LpFdcc&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="320" height="265" src="http://www.youtube.com/v/kjzs9LpFdcc&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;你空出一雙手　穿過黑夜握住我&lt;br /&gt;兩個人的手心裡有一整片寬闊的天空&lt;br /&gt;誰都沒有開口　星星也忘了閃爍&lt;br /&gt;有你陪著我就可以走到天涯的盡頭&lt;br /&gt;&lt;br /&gt;＃那時候　還記得那時候　從手心傳過來的溫柔&lt;br /&gt;　如果說　只能活這一天　曾經與你深深相愛　我已沒有遺憾&lt;br /&gt;&lt;br /&gt;＊我用回憶溫暖了想你的每一刻　不讓你離我太遙遠&lt;br /&gt;　走在這個適合擁抱的季節　愛在心裡所以我不可憐&lt;br /&gt;&lt;br /&gt;※回憶溫暖了想你的每一刻&lt;br /&gt;　緊緊抱著你說過的誓言&lt;br /&gt;　等待著我們說好的永遠&lt;br /&gt;&lt;br /&gt;並肩的兩個人　在銀白色的街頭&lt;br /&gt;印下的腳印還一直　在我的心裡往前走&lt;br /&gt;從愛的第一秒　直到最後一分鐘&lt;br /&gt;&lt;br /&gt;Repeat ＃,＊,※&lt;br /&gt;&lt;br /&gt;當走過的路流過的淚　被落葉掩沒&lt;br /&gt;是你的溫柔讓我的心重新活過來&lt;br /&gt;就算相愛的人無論如何暫時要離開&lt;br /&gt;別問未來怎麼辦　我只需要等待&lt;br /&gt;&lt;br /&gt;Repeat ＊,＊&lt;br /&gt;&lt;br /&gt;回憶溫暖了想你的每一刻　把最後的合照擺在窗前&lt;br /&gt;想像著你也許跟我一樣　正在倒數再見的時間&lt;br /&gt;等著給我說好的永遠&lt;/p&gt;
&lt;p&gt;（歌詞轉錄自：&lt;a href="http://music.fdlive.com/chua-joi/joi-17/08.html" target="_blank"&gt;華人歌詞網&lt;/a&gt;）&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-1378752798489870282?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/1378752798489870282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1378752798489870282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/1378752798489870282'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/blog-post.html' title='中島美嘉 - 雪の華(雪之華)'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-556400220017661134</id><published>2010-02-12T08:33:00.000+08:00</published><updated>2010-06-05T05:11:16.337+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='趨光'/><title type='text'>Logorama</title><content type='html'>&lt;p&gt;在&lt;a href="http://gizmodo.com/5469410/watch-oscar-nominated-short-logorama-now-+-really-watch-it" target="_blank"&gt;Gizmodo&lt;/a&gt;看到這個提名2010奧斯卡Best Animated Short的短片，麥當勞叔叔果然怎麼看都是邪惡怪叔叔。看了這個影片後，也覺得如果有個"7-11rama"可能也相當可觀，應該會有open小將抓狂或亂殺人的場面。&lt;/p&gt;
&lt;p&gt;
&lt;object width="480" height="295"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/epitjscZEOA&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="480" height="295" src="http://www.youtube.com/v/epitjscZEOA&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;object width="480" height="295"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/78skowxn7J4&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" /&gt;
&lt;param name="allowfullscreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="480" height="295" src="http://www.youtube.com/v/78skowxn7J4&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2732629504988178457-556400220017661134?l=tagtraumhouse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tagtraumhouse.blogspot.com/feeds/556400220017661134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/logorama.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/556400220017661134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2732629504988178457/posts/default/556400220017661134'/><link rel='alternate' type='text/html' href='http://tagtraumhouse.blogspot.com/2010/02/logorama.html' title='Logorama'/><author><name>tagtraum</name><uri>http://www.blogger.com/profile/04524223409333530714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2732629504988178457.post-1753525514032203388</id><published>2010-02-12T03:58:00.000+08:00</published><updated>2010-06-05T05:11:16.338+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lists'/><title type='text'>list: 2009年看的電影</title><content type='html'>&lt;p style="text-align: right;"&gt;last update: 2010.2.12&lt;/p&gt;
&lt;p style="text-align: right;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="text-alig
