CPE 1 star problems

題目 (測試程式) 題號 題目摘要 使用語法 測試資料
1. Vito's family CPE10406,
未出過,
UVa10041
ZJ a737, a941
計算群集中心點 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
ZJ a012

計算人數差 while loop, subtraction
10 12
10 14
100 200
3. Primary Arithmetic

CPE10404,
20101223 #4,
20110525 #1,
UVa10035
ZJ c014

計算進位位數 while loop, array, function
123 456
555 555
123 594
898 99998
0 0
4. The 3n + 1 problem CPE10400,
20100609 #1,
UVa100
ZJ c039
計算 i 到 j 中所有數字的最大 cycle
length
while loop, max, if, function
1 10
100 200
201 210
900 1000
5. You can say 11 CPE10460,
20111220 #2,
UVa10929
ZJ d235
測試 11 的倍數 while loop
112233
30800
2937
323455693
5038297
112234
0
6. Bangla Numbers

CPE10414,
20181218 #3
測資有錯,
UVa10101

以 Bangali numerals
印出數字 (0 到底要不要印出? 題目沒有描述 0 kuti 的特殊處理方式)
while loop, for loop, selection,
function, long long
23764
45897458973958
12340050000100

123456001234567
7. List of Conquests CPE21924,
20190326 #3,
UVa10420
ZJ a743
統計並印出每一國的美女的數目 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,
20110927 #2,
UVa10008
ZJ c044
字母出現頻率分析 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
ZJ e578
簡單的字母對照表 array, if, while loop
k[r dyt I[o
10. Problem J: Summing Digits CPE10473,
20121218 #1,
20151222 #1,
UVa11332
ZJ c813
複合函數執行的極限 function, loop
2
11
47
1234567892
1234567
234567
23467
24675
0
11. Common Permutation CPE10567,
未出過,
UVa10252
ZJ e507
找出兩個字串中共同的字元 (具有某種相同排列的最長子字串, 子字串不需要是連續的字元) array, for loop
pretty
women
walking
down
the
street
12. Rotating Sentences CPE21914,
20151006 #2,
UVa490
ZJ c045
旋轉 90 度
列印字句
for loop, two-dim array, selection
Rene Decartes once said,
"I think, therefore I am."
13. TeX Quotes CPE22131,
20110525 #2,
UVa272
ZJ c007
以 `` 或是 ''
取代 "
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 (PE22801,
20111220 #3,
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,
20121218 #3,
20170328 #2,
UVa10038
ZJ d097
檢查數列是否 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,
20170523 #3,
UVa10056
ZJ e510
運用級數公式計算多人遊戲的機率 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,
20120925 #2,
UVa10170
ZJ e555
運用等差級數和公式 while loop, sqrt()
1 6
3 10
3 14
1553 999299999999999
9999 999999999999999
18. 498-bis CPE10431,
20200526 #1,
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,
20140527 #1,
UVa10783
ZJ c022
範圍內奇數
的總和
for loop
2
1
5
3
5
20. Beat the Spread! CPE10454,
未出過,
UVa10812
ZJ c004
簡單聯立方
程式, s=a+b,
d=a-b 求 a, b
selection, +, -, /
2
40 20
20 40
21. Symmetric Matrix CPE10478,
20190924 #1,
UVa11349
ZJ e513
檢查是否為對稱矩陣 (題目敘述 "每一元素為正數" 可能有錯) 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
ZJ d186
計算 a 到 b 中間有幾個平方數 sqrt(), selection
1 4
1 10
7 12345
0 0
23. B2-Sequence CPE23621,
未出過,
UVa11063
ZJ d123
檢查是否滿足所有 bi + bj 都不等 4 layers of for loops, array
4
1 2 4 8
24. Back to High School Physics CPE10411,
20171219 #2,
UVa10071
ZJ d226
推導速度與位移公式 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,
20160524 #3,
UVa948
ZJ a134
以特別的進位制表示數字 while loop, for loop,
function, array, %
12
1
2
3
4
5
6
7
8
9
10
123465
100000000
27. Funny Encryption Method CPE10403,
20130528 #1,
UVa10019
ZJ e545
進位制轉換 while loop, for loop, function, %
4
265
111
1234
9874319
28. Parity CPE10461,
20140325 #1,
UVa10931
ZJ a132
計算 同位位元 while loop, array, function, %
1
2
10
21
2147483647
0
29. Cheapest Base CPE10466,
20120327 #1,
20141223 #3,
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,
20120925 #3,
20201020 #1,
UVa10050
ZJ e579
計算多個數字倍數之聯集 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,
20120925 #4,
UVa10193
ZJ d306
進位制轉換 + gcd while loop, array, gcd, function
5
11011
11000
11011
11001
111111
100
1000000000
110
1010
100
32. Divide, But Not Quite Conquer! CPE10419,
20131001 #1,
UVa10190
ZJ e566
檢查是否為 1, n, n^2, n^3, n^4, ... while loop, if
125 5
30 3
80 2
81 3
33. Simply Emirp CPE10428,
20131217 #2,
UVa10235
ZJ d387
檢查是否為質數, 反轉是否為質數 while loop, function, for loop
17
18
19
179
199
9123461
9800003
9900047
9900049
34. 2 the 9s CPE10458,
20150324 #2,
UVa10922
ZJ d672
檢查 9 的倍數 recursive function, while loop, array
999999999999999999999
9
9999999999999999999999999999998
0
35. GCD CPE11076,
20191217 #2,
UVa11417
ZJ d255
計算最大公因數 recursive function, for loop
10
100
500
0
幾何與座標
36. Largest Square CPE10456,
20150526 #3,
UVa10908
ZJ e575

在 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,
20190528 #3,
UVa10221
計算圓弧以及切線長度 while loop, atan(), sqrt()
500 30 deg
700 60 min
200 45 deg
38. Can You Solve It? CPE10447,
20110927 #1,
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,
20161220 #2,
UVa10242
ZJ e512
找到平行四邊形的第四個端點 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
ZJ e606
計算群集中心點 for loop, array, change
representation, if, malloc(), free()
2
10
10
4
1
2
2
4
41. Tell me the frequencies! CPE10410,
20160322 #3,
UVa10062
ZJ c012
計算字母出現頻率, 排序列印 while loop, for loop,
qsort, two-dim array
AAABBC
122333
42. Train Swapping CPE22811,
20170926 #4,
UVa299
ZJ e561
計算需要交換相鄰的兩個元素幾次可以還原原本順序 while loop, for loop
3
3
1 3 2
4
4 3 2 1
2
2 1
43. Hardwood Species CPE10426,
未出過,
UVa10226
ZJ d492

計算各品種樹木的比例 (排序與搜尋)

由於樹木品種可能有 10000 種, 最多可能有 1000000 棵術, 不用二分搜尋一定會 TLE, 因此實作時需要建立一個平衡的二元樹 (例如 AVL 樹), 才能避免不斷地排序, 否則就需要使用 STL 的 map, CPE 還沒有真的出在正式考試中出過。

while loop, string processing, array,
sorting, function (struct and qsort)

AVL balanced binary tree or std::map

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,
20200609 #2,
UVa10189
ZJ e605

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

while loop, 4 layers of for loops,
string processing
4 4
*...
....
.*..
....
3 5
**...
.....
.*...
0 0
45. Die Game CPE11019,
20140923 #2,
20181002 #2,
UVa10409
ZJ e516
模擬骰子滾動 while loop, function, array
1
north
3
north
east
south
0
46. Eb Alto Saxophone Player

CPE11020,
20101011 #7,
20161004 #3,
20201222 #3
測資B過長,
UVa10415
ZJ e531

薩克斯風按鍵: 模擬計算每一指按壓次數 for loop, function, two-dim array
3
cdefgab
BAGFEDC
CbCaDCbCbCCbCbabCCbCbabae
47. Mutant Flatworld Explorers CPE23641,
20120529 #3
20180327 #3,
UVa118
ZJ c082
模擬機器人的運動以及學習 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,
20101223 #2,
UVa11150
ZJ d189
尋找退瓶的最佳策略

while loop

8
49. Sort! Sort!! And Sort!!! CPE11069,
20180529 #3,
UVa11321

ZJ d750
排序! 排序!! 還是排序!! sort
% operator and
overflow
15 3
15
9
3
6
12
13
7
1
4
10
11
5
2
8
14
0 0

程式設計課程 首頁

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