作詞:林秋離 作曲:林俊傑
醒著像睡著 躺著像思考 神魂顛倒
感情太單調 竟然是煩惱 如何是好
也許來陣風雨 花謝滿地
黯然神傷的困擾
可以刺激那顆 渾渾噩噩
失去了烈火 激情的大腦
吹風就感冒 淋雨就發燒 有愛就好
#我不再逃 空虛日子 這一路都在熬
也許愛情就是熟能生巧
你絕對想不到我多渴望
讓生活染上一些顏料
是紅橙黃或藍靛紫都好
一圈一圈的圍繞
終於能自在的坦誠說愛你
火一點就燃燒
怎麼刺激那顆 渾渾噩噩
失去了烈火 激情的大腦
吹風就感冒 淋雨就發燒 有愛就好
Friday, December 24, 2010
林俊傑 - 熟能生巧
Tuesday, November 23, 2010
Monday, November 22, 2010
Saturday, November 20, 2010
A Web App
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.
It is really amazing to have database functionality without having to maintain a database server.
feel free to try it and add some new entries on tagtraumapp.appspot.com.
Friday, November 19, 2010
Google App Engine !
Which is really cool. Enjoyed the excitement of cloud computing for the first time!
Friday, November 12, 2010
周柏豪 - 走狗
作曲: 張佩瑩
填詞: 林夕
吃我最不喜愛料理 吃到我歡喜
有了你犧牲我習慣 免惹你生氣
如果爭執只想討好你 不必講理
還期望穿衣穿到彷彿 很襯你
像你所講隨時要聽候 你都講過愛是終身獻奉
不計較亦無求 原來未足夠
勉強遷就 只可加劇你渴求
依足你任何吩咐 更無權去攔住你拖手
誰想到聽講聽教令我個性也生銹
誰想到只聽你話連自尊也再沒有
馴服地吠不出口 令你我也看不起我遞上手
會拖多幾晝
像你所講難捱也接受 你都講過愛是堅忍退讓
將妥協換自由 原來未足夠
我的溫柔 根本不是你所求
依足你任何吩咐 更無權去攔住你拖走
誰想到聽講聽教令我個性也生銹
誰想到只聽你話連自尊也再沒有
馴服地吠不出口 令你我也看不起我
只敢附和 只懂求和 情感拖得太久
誰相信嘔心瀝血令我血性也失守
明白我賣相全為迎合你醜到未知醜
誰連賣力討好你令我變了你的狗 命我走 便要走
寵你寵到嘔心瀝血令我血性也失守
明白我賣相全為迎合你醜到未知醜
誰連賣力討好你令我變了你的狗 若我走 我終於忍夠
周柏豪 - 最好不過
作曲:陳光榮
填詞:馮曦妤
編曲:周柏豪 / 陳光榮
監製:舒文 / 陳光榮
叮囑我小心 千句萬句
看顧在身邊 一歲又一歲
生長於小堡壘 是我仍陶醉
愉快在於 簡單喝汽水
走出這溫室 奔向夢想追
風雨下濕身 走到肉身都破碎
人大了為何憔悴 愉快為何減退
太過累 偏偏收到來自你掌心的汽水
餘生都不會掉低我 全因有你 荊棘困難撐得過
當宇宙逆轉過 家裡仍像當初
磨練過 勞累過 回家最好不過
當我又出走 從來沒追究
當軟弱灰心 誰人像好友
即使我事事犯錯 體恤我亦肯定我
安撫我 開心簡單來做我 不必想太多
餘生都不會掉低我 全因有你 荊棘困難撐得過
當宇宙逆轉過 家裡仍像當初
磨練過 勞累過 回家最好不過
餘生都不會掉低我 全因有你 荊棘困難撐得過
當宇宙逆轉過 家裡仍像當初
流淚過 沉澱過 回家最好不過
周柏豪 - 乞丐王子
作曲:周博賢
填詞:周博賢
編曲:周博賢
監製:周博賢
披搭著污穢破碎故衣 執拾著棄置膠袋似失理智
那灰黑眼窩憂鬱帶點失意
生活在下層談何容易 坑伴饅頭被浸濕都不介意
耐性進食不放肆
充當瘋漢半輩子 給笑太過癡 突然被世界注視千萬次
留言像諷刺 衣著具創意 人氣飆升不止
他身處赤貧有誰會在意 他身世永被當玩笑玩意
他心理變異還是理智 為何全沒鬥志 變餐桌間的事
他一切照舊每日繼續試 找生計過活卻未太如意
身邊每一個都介意 這個乞男兒 討最低工資都不得已
出身清苦無財無人事 低學歷卻有不死鳥的意志
每天工作擔舉洗刷都可以
可是現實拿窮人歧視 爭逐上游沒契機灰心喪志
受壓過度失理智
充當瘋漢半輩子給笑太過癡 突然被世界注視千萬次
留言像諷刺 衣著具創意 連遠方鄉親也知
他身處赤貧有誰會在意 他身世永被當玩笑玩意
他心理變異還是理智 為何全沒鬥志 變餐桌間的事
他一切照舊每日繼續試 找生計過活卻未太如意
身邊每一個都介意 這個乞男兒 討最低工資都不得已
世態詭異 雖耕種肯去試 期望會結果實幼稚
即使滿腔戰意 永不躲懶實幹過日子
因果已前後倒置 滅貧仍沒有法子
他多悲慘哪有誰會在意 他身世秘密當玩笑玩意
他心理變異還是理智 為何隨地上廁 要窺探得個「知」
他穿梭鄉鎮每日拼命試 找生計過活卻遇上敵意
身邊每位眼光懷疑 憎厭這男兒 討最低工資都不可以
Tuesday, November 2, 2010
Install northwind and pubs sample database on SQL Server 2008
I’m pretty new to database. This is how I installed northwind and pubs sample database on SQL Server 2008.
1. Download “SQL2000SampleDb.msi” and execute the msi file, which will extract files under “C:\SQL Server 2000 Sample Databases”
2. Run “SQL Server Management Studio” and connect to “Database Engine”
3. Choose File->Open->File and select the “instnwnd.sql” (for northwind database) or “instpubs.sql” (for pubs database) under “C:\SQL Server 2000 Sample Databases” folder.
4. Click “Execute” on the toolbar or “Query->Execute” to execute the sql commands.
Sunday, October 31, 2010
My ACM Solved Problem List
Volumn I
100 - The 3n + 1 problem
101 - The Blocks Problem
102 - Ecological Bin Packing
103 - Stacking Boxes
104 - Arbitrage
105 - The Skyline Problem
106 - Fermat vs. Pythagoras
108 – Maximum Sum
109 – SCUD Buster
110 - Meta-Loopless Sorts
111 – History Grading
112 – Tree Summing
113 – Power of Cryptography
114 – Simulation Wizardry
115 – Climbing Trees
116 – Unidirectional TSP
117 - The Postal Worker Rings Once
118 - Mutant Flatworld Explorers
119 - Greedy Gift Givers
120 - Stacks of Flapjacks
121 - Pipe Fitters
122 – Trees on the level
123 – Searching Quickly
124 – Following Orders
125 – Numbering Paths
126 - The Errant Physicist
127 - "Accordian" Patience
128 - Software CRC
129 – Krypton Factor
130 – Roman Roulette
131 - The Psychic Poker Player
132 - Bumpy Objects
133 – The Dole Queue
134 - Loglan-A Logical Language
135 – No Rectangles
136 – Ugly Numbers
137 – Polygons
138 – Street Numbers
Volumn III
Volumn V
Volumn VI
Volumn IX
list: 2010年看的戲劇
last update: 2010.10.31
港 | |
***** | 公主嫁到(2010) |
***** | 疑情別戀(2008) |
*** | 古靈精探B(2009) |
台 | |
** | 轉角遇到愛(2007) |
韓 | |
****+ | Air City(2007) |
*** | Pasta |
** | 拜託小姐 |
日 | |
**** | 四個謊言/四謊記(2008) |
list: 2010年看的電影
last update: 2010.11.1
**** | Shoot ‘Em Up (2007) |
*** | 21 (2008) |
** | The Da Vinci Code (2006) |
***+ | 賭神3之少年賭神 (1996) |
*** | 雀聖2自摸天后 (2005) |
** | 獨家試愛 (2006) |
**** | Inception (2010) |
Jul | |
**** | District 9 (2009) |
** | The Bounty Hunter (2010) |
**** | 72家租客 (2010) |
**** | Couples Retreat (2009) |
*** | Cloudy with a Chance of Meatballs (2009) |
Jun | |
*** | Date Night (2010) |
***** | Up in the Air (2009) |
*** | 重慶森林 (1994) |
**** | 下弦之月 (2004) |
May | |
****+ | Breakfast at Tiffany's (1961) |
Mar | |
**** | 螢火蟲之墓 (火垂るの墓) (1988) |
**** | Alice in Wonderland (2010) (3D Version) |
**** | Modern Times (1936) |
**+ | The Lovely Bones (2009) |
****+ | Artificial Intelligence: AI (2001) |
*** | Lilo & Stitch 2: Stitch Has a Glitch (2005) |
*** | Lilo & Stitch (2002) |
*** | Monster Inc. (2001) |
**+ | 老港正傳 |
Jan | |
***+ | 2012 (2009) |
** | (500) Days of Summer (2009) |
** | 得閒飲茶 (2006) |
*** | 天水圍日與夜 (2008) |
Friday, October 29, 2010
Friday, October 22, 2010
ACM: 674 – Coin Change
Another coin change problem, much the same as 357. I experimented replacing cin/cout by scanf/printf, and the runtime do reduced dramatically!
CODE
#include <iostream>
enum { MAX = 7489, COINS = 5 };
int main(){
const int coin[] = {1, 5, 10, 25, 50};
long long w[MAX+1] = {};
w[0] = 1;
for(int i=0; i<COINS; ++i)
for(int j=coin[i]; j<=MAX; ++j)
w[j] += w[j-coin[i]];
int n;
while( scanf("%d", &n) != EOF )
printf("%d\n", w[n]);
return 0;
}
ACM: 357 – Let Me Count The Ways
Straightforward DP coin change problem. To find the number of possible ways that make up certain amount of money.
My runtime is 0.012. Maybe the way to further reduce runtime is reducing times of i/o?
CODE
#include <iostream>
enum { MAX = 30000 };
int main(){
const int coin[] = {1, 5, 10, 25, 50};
long long w[MAX+1] = {};
w[0] = 1;
for(int i=0; i<5; ++i)
for(int j=coin[i]; j<=MAX; ++j)
w[j] += w[j-coin[i]];
int n;
while( scanf("%d", &n) != EOF )
if( w[n] == 1 )
printf("There is only 1 way to produce %d cents change.\n", n);
else
printf("There are %lld ways to produce %d cents change.\n", w[n], n);
return 0;
}
ACM: 166 – Making Change
換零錢的問題,要使用有限量的錢幣去支付一個商品,要找出支付和找錢(假設商家錢幣為無限量)所使用的總錢幣數量為最小。我的做法是,先找出在每一個金額,商家找錢使用的最少錢幣數量。然後根據買家的錢幣組合,找出所有可以支付的金額所使用的最少錢幣數量。最後找出支付+找錢總使用最少的錢幣數量。
在計算支付的部分,似乎怪怪的,應該有更有效率的做法,但是還想不到怎麼改,繼續研究。
CODE
#include <iostream>
#include <climits>
using namespace std;
enum { COINS = 6, MAX_CHANGE = 10000 };
int main(){
const int coin[] = {1, 2, 4, 10, 20, 40};
int p, q, //price
w[COINS], //wallet
change[MAX_CHANGE+1]; //change
int i, j, k, m, sum;
change[0] = 0;
for(i=1; i<=MAX_CHANGE; ++i)
change[i] = INT_MAX;
for(i=0; i<COINS; ++i)
for(j=coin[i]; j<=MAX_CHANGE; j++)
change[j] = min(change[j-coin[i]]+1, change[j]);
while(1){
sum = 0;
for(i=0; i<COINS; ++i){
scanf("%d", &w[i]);
sum += w[i] * coin[i];
}
if( sum == 0 ) break;
scanf("%d.%d", &p, &q);
p = (p*100+q)/5;
int* pay = (int*)malloc((sum+1) * sizeof(int));
int* use = (int*)malloc((sum+1) * sizeof(int));
if( pay == NULL || use == NULL ) exit(1);
pay[0] = 0;
for(i=1; i<=sum; ++i)
pay[i] = INT_MAX;
for(i=0; i<COINS; ++i){
for(j=1; j<=coin[i]; ++j){
m = w[i];
for(k=j; k<=sum; k+=coin[i]){
if( pay[k] != INT_MAX ){
m = w[i];
}
else if( k < coin[i] ){ break; }
else if( m > 0 ){
pay[k] = pay[k-coin[i]] + 1;
--m;
}
}//k
}//j
memset(use, 0, (sum+1) * sizeof(int));
for(j=coin[i]; (j<=sum) && (use[j-coin[i]] < w[i]) ; ++j){
if( (pay[j-coin[i]] != INT_MAX) && (pay[j-coin[i]]+1 <= pay[j]) ){
pay[j] = pay[j-coin[i]] + 1;
use[j] = use[j-coin[i]] + 1;
}
}
}//i: coins
int total = INT_MAX;
for(i=p; i<=sum; ++i)
if( pay[i] != INT_MAX )
total = min(pay[i]+change[i-p], total);
printf("%3d\n", total);
free(pay);
free(use);
}
return 0;
}
Wednesday, October 20, 2010
ACM: 147 - Dollars
也是一直想學的DP換零錢問題,很有趣。
NOTE
注意浮點數誤差的問題
REFERENCE
CODE
#include <iostream>
enum { MAX = 300 * 100 / 5, COINS = 11 };
int main(){
const int coin[] = {1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000}; //value*100/5
long long r[MAX+1];
int i, j;
for(i=0; i<=MAX; ++i)
r[i] = 1;
for(i=1; i<COINS; ++i)
for(j=coin[i]; j<=MAX; ++j)
r[j] = r[j-coin[i]] + r[j];
while( (scanf("%d.%d", &i, &j) != EOF) && (i+j != 0) )
printf("%3d.%02d%17lld\n", i, j, r[(i*100+j)/5]);
return 0;
}
ACM: 624 - CD
Straightforward 0/1 Knapsack problem. Tried malloc, memset, free in 2D array.
CODE
#include <iostream>
enum { TRACK = 30 };
int main(){
int n, t, d[TRACK];
int i, j;
while( scanf("%d%d", &n, &t) != EOF ){
for(i=0; i<t; ++i)
scanf("%d", &d[i]);
//malloc
bool** pick = (bool**)malloc(t * sizeof(bool*));
for(i=0; i<t; ++i)
pick[i] = (bool*)malloc((n+1) * sizeof(bool));
int* tape = (int*)malloc((n+1) * sizeof(int));
if( pick == NULL || tape == NULL )
exit(1);
for(i=0; i<t; ++i)
memset(pick[i], 0, (n+1)*sizeof(bool));
memset(tape, 0, (n+1)*sizeof(int));
for(i=t-1; i>=0; --i){
for(j=n; j>=d[i]; --j){
if( tape[j-d[i]]+d[i] > tape[j] ){
tape[j] = tape[j-d[i]] + d[i];
pick[i][j] = 1;
}
}//j
}//i
for(i=0, j=n; i<t; ++i){
if( pick[i][j] ){
printf("%d ", d[i]);
j -= d[i];
}
}
printf("sum:%d\n", tape[n]);
//free
for(i=0; i<t; ++i)
free(pick[i]);
free(pick);
free(tape);
}
return 0;
}