2014年3月8日 星期六

UVa OJ - 10305 Ordering Tasks

The following program is my ACcepted code for UVA-10305.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10305 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

NTHU OJ - 7091 PA - Sum (較快版 Faster Version)

The following program is my ACcepted code for NTHU-7091 (fast version).
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7091 (fast version) 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

之前這篇的程式是比較慢的XD,可能會在嚴格的測資中TLE,所以就有了這個比較快的版本!

This previous article's program is slower. Maybe get TLE when there're serious test cases so I write this faster version.

NTHU OJ - 2706 The Frog's Games (HDU 4004)

The following program is my ACcepted code for NTHU-2706 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 2706 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem! (NTHU 2706 中文題目)

點這裡看題目 Click here to see this Problem! (HDU    4004 英文題目)

2014年3月7日 星期五

NTHU OJ - 7091 PA - Sum

The following program is my ACcepted code for NTHU-7091 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7091 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

這是比較慢的版本,在嚴格測資中可能TLE,請看這個新的較快版!

This article's program is slower. Maybe get TLE when there're serious test cases.
 Please see this faster version.

2014年3月6日 星期四

UVa OJ - 674 Coin Change

The following program is my ACcepted code for UVA-674 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 674  的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


我之後應該會寫一小篇來解釋這種題目的 DP 思路
但可能要等一小段時間了,如果很想知道的話可以留言,我會趕快寫
I think I will write a small article to explain this problem's DP thought,
but that will in the future some time(?).
If you want to know about that, please leave a commend and I will work on it soon.

此題目可以使用int,因為他的n值比較小。
This problem can be solved when you use int because its n may be smaller.

2014年3月5日 星期三

UVa OJ - 10071 Back to High School Physics

The following program is my ACcepted code for UVA-10038 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10038 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


一個簡單的高中物理題
讓我們回想一下這個方程式: V = V0 + a * t
我把 2 倍時間的速度稱為 "V2"
此V2 =  V0 + 2 * a * t
而經過 2 倍時間的位移 = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !

It's a simple High School Physics.
Let's remind this equation: V = V0 + a * t .
I call the V in twice of that time "V2".
This V2 = V0 + 2 * a * t .
and the displacement be in twice of that time = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !

Fun Stuff 歡樂東東 - Short Comics 翻譯短篇漫畫 (一)


下面附上英文原圖方便參考 :P
Below is the English Original Picture for your reference.


2014年3月4日 星期二

UVa OJ - 10038 Jolly Jumpers

The following program is my ACcepted code for UVA-10038 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10038 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


UVa OJ - 10062 Tell me the frequencies!

The following program is my ACcepted code for UVA-10062 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10062 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

這題被 "A blank line should separate each set of output. " 偷襲到了。
是每個test case 中間要格一行空白,最後一個case後面不能空白
所以我在除了第一個case後面的每個case都先輸出一行空白。

Because the problem said "A blank line should separate each set of output.",
between cases, there should be a blank line. (the last case is not needed)

NTHU OJ - 7645 PA - Cake V.S. Rational number

The following program is my ACcepted code for NTHU-7648 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7648 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

題目說 "特別注意:行末不得有空白。"
所以我以為是測資間需要一行空白,但是最後不能空白
但這樣會拿到很多WA
最後我在每個測資後面都輸出一行空白,就AC了...

UVa OJ - 357 Let Me Count The Ways

The following program is my ACcepted code for UVA-357 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 357 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


我之後應該會寫一小篇來解釋這種題目的 DP 思路
但可能要等一小段時間了,如果很想知道的話可以留言,我會趕快寫
I think I will write a small article to explain this problem's DP thought,
but that will in the future some time(?).
If you want to know about that, please leave a commend and I will work on it soon.

因為 n 的index範圍會大到30000
那會讓答案超過int範圍,
所以我使用int int long
如果是UVA 674 Coin Change,就可以使用int
因為他的n值比較小

Because the index range from 1 to 30000,
it will over the int range!
so I used long long int
The UVa 674 Coin Change can be solved when you use int
because its n may be smaller.

2014年3月3日 星期一

NTHU OJ - 7648 PD - Mine Threat

The following program is my ACcepted code for NTHU-7648 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7648 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

NTHU 7653 PD - Pick Up Thumbtacks 簡直是一模一樣
有興趣可以點上面連結
本題是找遠到近 ~

NTHU OJ - 7520 PA - Watermelon

The following program is my ACcepted code for NTHU-7520 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7520 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

2014年3月2日 星期日

UVa OJ - 10370 Above Average

The following program is my ACcepted code for UVA-10370 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10370 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

UVa OJ - 10041 Vito's family

The following program is my ACcepted code for UVA-10041 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10041 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


UVa OJ - 10327 Flip Sort

The following program is my ACcepted code for UVA-10327 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 10327 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

UVa OJ - 12149 Feynman

The following program is my ACcepted code for UVA-12149 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 12149 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

一個簡單的數學問題
當邊為 1 時,會有  n  *  n   squares.
當邊為 2 時,會有(n-1)*(n-1) squares.
.
.
直到...
當邊為 n 時,會有  1  *  1   squares.
全部加總會得到答案!

A simple math problem.
When the edge = 1, there're  n  *  n   squares.
When the edge = 2, there're(n-1)*(n-1) squares.
.
.
Until..
When the edge = n, there're  1  *  1   squares.
Then add them to get the answer.

NTHU OJ - 7653 PD - Pick Up Thumbtacks

The following program is my ACcepted code for NTHU-7653.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7653 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

NTHU 7648 PD - Mine Threat 簡直是一模一樣
有興趣可以點上面連結
本題是找近到遠 ~

NTHU OJ - 1003 OTAKU

The following program is my ACcepted code for NTHU-7488.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃NTHU 7488 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

我認為也可使用暴力單純一個個搜尋 (時間限制是10秒)
但是我是使用map的簡單應用AC
我之前習慣使用 (m[tmpStr] != 0) 來代表之前沒有存入 map 中的 key 值
但可能因為 map 之前沒有 access 過這個key值,所以 NTHU OJ把這種狀況視為 Runtime Error(SIGABRT).
改成 if(m.count(tmpStr) > 0) 即可AC

I think using brute force to search the key is still fine. (time limit: 10 s)
But I use simple STL map to solve it.
I used to apply (m[tmpStr] != 0) to represent the key, which was not saved in map.
But maybe map didn't access this key value so NTHU OJ think that's Runtime Error(SIGABRT).
I modifed it to if(m.count(tmpStr) > 0) and got AC.

UVa OJ - 11321 Sort! Sort!! and Sort!!!

The following program is my ACcepted code for UVA-11321.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃UVA 11321 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )

點這裡看題目 Click here to see this Problem!

這題跟我之前所解的 UVA 612 DNA Sorting 寫法蠻相似的
請參考這理的解說:

This problem is similar with one of my solved problem:  UVA 612 DNA Sorting
Please see this for reference.