CPE 1 star problems

題目 (測試程式) 題號 題目摘要 使用語法 測試資料
1. Vito's family (CPE10406,
UVa10041)
計算群集中心點 for loop, array, if
5
2 2 4
3 2 4 6
11 1 3 3 4 2 6 7 7 8 3 9
8 2 2 5 3 4 8 9 6
15 9 9 8 7 7 10 11 13 2 5 3 3 3 6 1
2. Hashmat the brave warrior (CPE10407,
UVa10055)
計算人數差 while loop, subtraction
10 12
10 14
100 200
3. Primary Arithmetic (CPE10404,
UVa10035)
計算進位位數 while loop, array, function
123 456
555 555
123 594
898 99998
0 0
4. The 3n + 1 problem (CPE10400,
UVa100)
計算 i 到 j 中所有
數字的最大 cycle
length
while loop, max, if, function
1 10
100 200
201 210
900 1000
5. You can say 11 (CPE10460,
UVa10929)
測試 11 的倍數 while loop
112233
30800
2937
323455693
5038297
112234
0
6. Bangla Numbers (CPE10414,
UVa10101)
以 Bangali numerals
印出數字 (0 到底
要不要印出?)
while loop, for loop, selection,
function, long long
23764
45897458973958
12340050000100
7. List of Conquests (CPE21924,
UVa10420)
統計並印出每一國
的美女的數目
while loop, string processing,
array, sorting, function
6
Spain Donna Elvira
England Jane Doe
Spain Donna Anna
Spain Elaine Bejar
England Mary Church
Germany Ada Ackerman
字元與字串
8. What's Cryptanalysis? (CPE10402,
UVa10008)
字母出現頻率
分析
array, if, for loop
3
This is a test.
Count me 1 2 3 4 5.
Wow!!!! Is this question easy?
9. Decode the Mad man (CPE10425,
UVa10222)
簡單的字母
對照表
array, if, while loop
k[r dyt I[o
10. Problem J: Summing Digits (CPE10473,
UVa11332)
複合函數執行
的極限
function, loop
2
11
47
1234567892
1234567
234567
23467
24675
0
11. Common Permutation (CPE10567,
UVa10252)
找出兩個字串
中共同的字元
(具有某種相
同排列的最長
子字串, 子字串
不需要是連續
的字元)
array, for loop
pretty
women
walking
down
the
street
12. Rotating Sentences (CPE21914,
UVa490)
旋轉 90 度
列印字句
for loop, two-dim array, selection
Rene Decartes once said,
"I think, therefore I am."
13. TeX Quotes (CPE22131,
UVa272)
以 `` 或是 ''
取代 "
while loop, getchar, state
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
數學計算
14. A - Doom's Day Algorithm (CPE22801,
UVa12019)
尋找最接近的
Doom's Day, 藉
以計算星期幾
array, function, for loop
8
1 6
2 28
4 5
5 26
8 1
11 1
12 25
12 31
15. Jolly Jumpers (CPE10405,
UVa10038)
檢查數列是否
Jolly Jumpers
while loop, for loop, selection, array
4 1 4 2 3
5 1 4 2 -1 6
16. What is the Probability!! (CPE10408,
UVa10056)
運用級數公式
計算多人遊戲
的機率
loop, pow(), formula derivation
7
2 0.166666 1
2 0.166666 2
5 0.214359 1
5 0.214359 2
5 0.214359 3
5 0.214359 4
5 0.214359 5
17. The Hotel with Infinite Rooms (CPE10417,
UVa10170)
運用等差級數
和公式
while loop, sqrt()
1 6
3 10
3 14
1553 999299999999999
9999 999999999999999
18. 498-bis (CPE10431,
UVa10268)
計算導函式值 array, for loop, function
7
1 -1
2
1 1 1
3
1 2 3 4 5 6 1 2 3
19. Odd Sum (CPE10453,
UVa10783)
範圍內奇數
的總和
for loop
2
1
5
3
5
20. Beat the Spread! (CPE10454,
UVa10812)
簡單聯立方
程式, s=a+b,
d=a-b 求 a, b
selection, +, -, /
2
40 20
20 40
21. Symmetric Matrix (CPE10478,
UVa11349)
檢查是否為對稱
矩陣 (題目敘述
"每一元素為正
數" 可能有錯)
while loop, two-dim array, for loop
2
N = 3
5 1 3
2 0 2
3 1 5
N = 3
5 1 3
2 0 2
0 1 5
22. Square Numbers (CPE10480,
UVa11461)
計算 a 到 b 中間
有幾個平方數
sqrt(), selection
1 4
1 10
7 12345
0 0
23. B2-Sequence (CPE23621,
UVa11063)
檢查是否滿足
所有 bi + bj
不等
4 layers of for loops, array
4
1 2 4 8
24. Back to High School Physics (CPE10411,
UVa10071)
推導速度與位移
公式
for loop
0 0
5 12
進位制轉換
25. An Easy Problem! (CPE10413,
UVa10093)
判定可能的最小
進位制
for loop, function, basic
array, string, long long, if, %
3
5
A
AA
ABC
ababc
ab0ACf
26. Fibonaccimal Base (CPE10401,
UVa948)
以特別的進位制
表示數字
while loop, for loop,
function, array, %
12
1
2
3
4
5
6
7
8
9
10
123465
100000000
27. Funny Encryption Method (CPE10403,
UVa10019)
進位制轉換 while loop, for loop, function, %
4
265
111
1234
9874319
28. Parity (CPE10461,
UVa10931)
計算 同位位元 while loop, array, function, %
1
2
10
21
2147483647
0
29. Cheapest Base (CPE10466,
UVa11005)
計算列印時最
省錢的進位制
while loop, array, function, %
2
10 8 12 13 15 13 13 16 9
11 18 24 21 23 23 23 13 15
17 33 21 23 27 26 27 19 4
22 18 30 30 24 16 26 21 21
5
98329921
12345
800348
14
873645
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
4
0
1
10
100
質數、因數與倍數
30. Hartals (CPE10517,
UVa10050)
計算多個數字
倍數之聯集
for loop, array
3
14
3
3
4
8
100
4
12
15
25
40
3650
7
11
13
17
15
12
25
37
31. All You Need Is Love! (CPE10421,
UVa10193)
進位制轉換 + gcd while loop, array, gcd, function
5
11011
11000
11011
11001
111111
100
1000000000
110
1010
100
32. Divide, But Not Quite Conquer! (CPE10419,
UVa10190)
檢查是否為 1, n,
n^2, n^3, n^4, ...
while loop, if
125 5
30 3
80 2
81 3
33. Simply Emirp (CPE10428,
UVa10235)
檢查是否為質數,
反轉是否為質數
while loop, function, for loop
17
18
19
179
199
9123461
9800003
9900047
9900049
34. 2 the 9s (CPE10458,
UVa10922)
檢查 9 的倍數 recursive function, while loop, array
999999999999999999999
9
9999999999999999999999999999998
0
35. GCD (CPE11076,
UVa11417)
計算最大公因數 recursive function, for loop
10
100
500
0
幾何與座標
36. Largest Square (CPE10456,
UVa10908)

在 M x N 的方陣
中找到以指定
(r,c) 為中心最
大的相同字元
方陣

for loop, two-dim array,
function, two-dim subarray
1
7 10 4
abbbaaaaaa
abbbaaaaaa
abbbaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaccaaaaaa
aaccaaaaaa
1 2
2 4
4 6
5 2
37. Satellites (CPE10424,
UVa10221)
計算圓弧以及
切線長度
while loop, atan(), sqrt()
500 30 deg
700 60 min
200 45 deg
38. Can You Solve It? (CPE10447,
UVa10642)
計算走幾步 for loop, long long, if, series sum
5
0 0 0 1
0 0 1 0
0 0 0 2
1 3 4 0
3 110 88899 2345
39. Fourth Point!! (CPE10566,
UVa10242)
找到平行四邊形
的第四個端點
while loop, if
0.000 0.000 0.000 1.000 0.000 1.000 1.000 1.000
1.000 0.000 3.500 3.500 3.500 3.500 0.000 1.000
1.866 0.000 3.127 3.543 3.127 3.543 1.412 3.145
3.127 3.543 1.866 0.000 3.127 3.543 1.412 3.145
1.866 0.000 3.127 3.543 1.412 3.145 3.127 3.543 
3.127 3.543 1.866 0.000 1.412 3.145 3.127 3.543
排序與中位數
40. A mid-summer night's dream (CPE10409,
UVa10057)
計算群集中心點 for loop, array, change
representation, if, malloc(), free()
2
10
10
4
1
2
2
4
41. Tell me the frequencies! (CPE10410,
UVa10062)
計算字母出現
頻率, 排序列印
while loop, for loop,
qsort, two-dim array
AAABBC
122333
42. Train Swapping (CPE22811,
UVa299)
計算需要交換
相鄰的兩個元素
幾次可以還原原
本順序
while loop, for loop
3
3
1 3 2
4
4 3 2 1
2
2 1
43. Hardwood Species (CPE10426,
UVa10226)
計算各品種樹
木的比例 (排序
與搜尋)
while loop, string processing, array,
sorting, function (struct and qsort)
2

Red Alder
Ash
Aspen
Basswood
Ash
Beech
Yellow Birch
Ash
Cherry
Cottonwood
Ash
Cypress
Red Elm
Gum
Hackberry
White Oak
Hickory
Pecan
Hard Maple
White Oak
Soft Maple
Red Oak
Red Oak
White Oak
Poplan
Sassafras
Sycamore
Black Walnut
Willow

Red Oak
Red Oak
White Oak
Poplan
Sassafras
模擬
44. Minesweeper (CPE10418,
UVa10189)

計算小地雷遊戲
中每一個點周圍
有幾個地雷

while loop, 4 layers of for loops,
string processing
4 4
*...
....
.*..
....
3 5
**...
.....
.*...
0 0
45. Die Game (CPE11019,
UVa10409)
模擬骰子滾動 while loop, function, array
1
north
3
north
east
south
0
46. Eb Alto Saxophone Player (CPE11020,
UVa10415)
薩克斯風按鍵
模擬計算每
一指按壓次數
for loop, function, two-dim array
3
cdefgab
BAGFEDC
CbCaDCbCbCCbCbabCCbCbabae
47. Mutant Flatworld Explorers (CPE23641,
UVa118)
模擬機器人的
運動以及學習
while loop, for loop, switch,
function, two-dim array
5 3
1 1 E
RFRFRFRF
3 2 N
FRRFLLFFRRFLL
0 3 W
LLFFFLFLFL
48. Cola (CPE11067,
UVa11150)
尋找退瓶的最佳
策略
while loop
8

程式設計課程 首頁

製作日期: 10/20/2015 by 丁培毅 (Pei-yih Ting)
E-mail: pyting@mail.ntou.edu.tw TEL: 02 24622192x6615
海洋大學 電機資訊學院 資訊工程學系 Lagoon