有些內容使用中英雙語,有些只有英文或中文。歡迎使用與分享任何內容,但先來信告知並標示此部落格為出處。
Some parts use both Chinese and English, but some parts use only one language. Feel free to share, but please contact me first and list this blog as your reference.

2014年3月3日 星期一

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.