ConsoleApplication1: Honai Tower
題目:
初始狀態下有三根柱子 ,分別為 ABC 三支 ,當中 A 柱擺上將要搬移的碟子 ,碟子由上到下依小到大疊好 ,分別編上號碼 1,2,3,4.... ,需將所有碟子全部搬移到 C 柱 ,規則為大碟不得擺在小碟上 ,也就是數字小者必須在前方
要求:
1.Input : 有幾個環,由上而下為 1,2,.....,N
2.Output: 每一步的動作的結果(輸出的要求是列出每一步驟後 ,各個柱子的情形 ,例:第一步由 A 搬 1 號碟到 C ,輸出便是: A(2,3)B()C(1))
3.三根柱子由左至右為 A,B,C
example:
Input : 2 (<-- 此數字為測試資料筆數)
3 (<-- 第一組測試數字)
4 (<-- 第二組測試數字)
Output: A(1,2,3)B()C() (<-- 一開始的初始狀態)
A(2,3)B()C(1) (<-- 第一步)
A(3)B(2)C(1) (<-- 第二步)
A(3)B(1,2)C()
A()B(1,2)C(3)
A(1)B(2)C(3)
A(1)B()C(2,3)
A()B()C(1,2,3)
A(1,2,3,4)B()C() (<-- 一開始的初始狀態)
A(2,3,4)B(1)C() (<-- 第一步)
A(3,4)B(1)C(2) (<-- 第二步)
A(3,4)B()C(1,2)
A(4)B(3)C(1,2)
A(1,4)B(3)C(2)
A(1,4)B(2,3)C()
A(4)B(1,2,3)C()
A()B(1,2,3)C(4)
A(1)B(2,3)C(4)
A(1)B(3)C(2,4)
A()B(1,3)C(2,4)
A(2)B(1,3)C(4)
A(1,2)B(3)C(4)
A(1,2)B()C(3,4)
A(2)B(1)C(3,4)
A()B(1)C(2,3,4)
A()B()C(1,2,3,4)
ConsoleApplication2: Knight's Tour
題目:
在一個8x8的棋盤中 ,給予一個 Knight 的起始位置 ,經過各位的程式運算後給出 Knight 走過棋盤的所有位置的序列
要求:
1.Input :有幾個 Knight 及每個 Knight 的起始位置
2.Output:棋盤中的每一位置以0~63來表示走的順序
3.為一 8X8 的棋盤
4.X 和 Y 座標中間以一個space來區隔
5.output的結果中 ,每個數字亦是以一個space來區隔
example:
Input : 2 (<-- 此數字為測試的資料筆數 ,也代表下面有兩列資料代表Knight的起始位置)
4 4 (<-- 第一個Knight的起始位置)
0 3 (<-- 第二個Knight的起始位置)
Output:
62 57 10 45 24 3 8 5
11 46 63 56 9 6 25 2
58 61 50 47 44 23 4 7
49 12 55 60 51 26 1 22
54 59 48 43 0 33 18 27
13 42 37 52 39 30 21 32
36 53 40 15 34 19 28 17
41 14 35 38 29 16 31 20
59 18 15 0 53 44 13 10
16 1 60 55 14 11 30 45
19 58 17 52 43 54 9 12
2 63 56 61 36 31 46 29
57 20 51 42 47 40 35 8
50 3 62 23 32 37 28 39
21 24 5 48 41 26 7 34
4 49 22 25 6 33 38 27
限制:
- 若有數個位置可以走的話,以右上角順時針方向為優先
- 請不要加上不必要的空白和,以免造成不必要的檢查錯誤
- Output file 的內容為ASCII code ,即上例的範例答案中 62 57 10 45 ......都是一個一個的字元而不是數字 ,請特別注意
ConsoleApplication3: A Mazing Problem
題目:
讀入一個陣列作為迷宮的資料 ,大小為 L*P(1<=L ,P<=10) ,以 0 代表沒有阻隔 ,而以 1 代表有阻隔 ,起始位置為 (1,1) ,出口位置為 (L,P) ,請設計一個演算法找出迷官的出路
限制:
- 我們訂行走的方向為先嘗試北邊是否有出路,之後以順時鐘方向作嘗試
- 一組答案的結束 ,請以兩個999表示 ,若結果為沒有路徑 ,請以兩個888表示
要求:
1.Input : 讀入指定之任意的 LxP 矩陣
2.Output: 找出一條從左上入右下出的路徑,用(i,j)來表示
example:
Input : 3 (<-- 有幾筆資料)
5 5 (<-- 迷宮大小 ROW*COL)
0 1 1 1 0 (<-- 迷宮的資料 , 0 為通路 , 1 為死路)
0 0 1 0 1
1 1 0 1 0
0 0 0 1 0
1 1 0 0 0
6 8
0 1 1 1 0 1 0 1
0 0 1 0 1 0 1 1
1 0 1 1 0 1 1 0
0 0 0 1 0 0 0 1
1 1 0 1 0 1 0 0
5 7
0 1 1 1 0 1 0
0 0 1 0 1 0 1
1 0 1 1 0 1 1
0 0 0 1 0 0 0
1 1 0 0 0 1 0
Output:
1 1 (<-- 路徑位置(ROW, COL) )
2 2
3 3
4 3
5 4
5 5
999 999 (<-- 一組答案的結束 ,請以兩個999表示)
888 888 (<-- 若結果為沒有路徑 ,請以兩個888表示)
999 999
1 1
2 2
3 2
4 3
5 3
5 4
5 5
4 5
4 6
4 7
5 7
999 999
ConsoleApplication4: Evaluation of Expressions
題目:
依要求轉換成所指定的 infix, prefix expression
要求:
1.Input : 讀入第一行表示所要轉換的資料數 ,每筆資料包含兩行 ,第一行表示所要轉換的keyvalue ,第二行表示其expression
2.Output: 表示成 infix 和 prefix expression
限制(四種keyvalue所代表的意義);
1 : 由 infix expression 轉 prefix expression
2 : 由 prefix expression 轉 infix expression
example:
Input : 2 (<-- 此數字為測試資料筆數)
1 (<-- 第一組轉換expression的keyvalue)
A/B-C+DE-AC(infix expression)
2 (<-- 第二組轉換expression的keyvalue)
-/A+BCDG (prefix expression)
Output: -+-/ABCDEAC (prefix expression)
A(B+C)/D-G (infix expression)
ps: operator只有 +,-,*,/,()
ConsoleApplication5: Equivalence Class
(A) Basic Concept
<a.1> The properties of the equivalence relation (≡):
(a) reflexive : x≡x
(b) symmetric : x≡y => y≡x
(c) transitive : x≡y,y≡z => x≡z
<a.2> We can use an equivalence relation to partition a set into equivalence classes.
Two members x and y of the input set, S, are in the same equivalence class if and only if x≡y.
<a.3> Example:
input set : S = {1,2,3,4,5,6};
relations : 1≡2, 3≡4, 1≡4, 5≡6
equivalence class: {1,2,3,4}; {5,6}
(B) Programming
Input Format : (Assume we have two testing pattern.)
#1# <-------Testing pattern 1
4 <------- The numbers of the relation
1 6 <------- Lower bound and upper bound of the input set
1 2 <------- Relation 1≡2
3 4 <------- 3≡4
1 4 <------- 1≡4
5 6 <------- 5≡6
#2# <------Testing pattern 2
2
1 3
1 2
1 3
Remark : There is one space symbol between two members of the input set.
Output Format :
#1# <------Output of testing pattern 1
2 <------ The numbers of the equivalence class
1 2 3 4 <------ Class 1(after sorting,i.e.,(1<2<3<4),(5<6),(1<5))
5 6 <------ Class 2
#2# <-----Output of testing pattern 2
1
1 2 3
Remark : There is one space symbol between two members of the input set.