# 前言 ### **高一基礎程式設計期中考** **很多人都在問我為什麼免修了還要來考試** **但其實免修$\neq$滿分** **免修只是拿到平常成績的40%而已** > **題外 : 聽說平常成績40%期中19%** > **加起來59% 看起來期末不讀不行XD** # Scoreboard **Skyoj的Rank感覺怪怪的不知道順序到底怎麼排的** **ps. 深綠色是首殺:)** :::spoiler **scoreboard** ![scorebroad](https://hackmd.io/_uploads/HkQatfbM0.jpg) ::: # 考試過程 ### **???** > **一開始的時候要登入帳號** > **結果我一直登不進去:(** > **到最後還是借用上一班的34號的帳號XD** > **登不進去我覺得是因為我第一次登入skyoj是在家裡登的** > **然後考試的時候被ip鎖掉:P** ### **解題順序** $14:32$ $pA$ <font color = "green">$AC$</font> $14:36$ $pB$ <font color = "red">$WA$</font> $14:38$ $pB$ <font color = "green">$AC$**(second submission)**</font> $14:41$ $pC$ <font color = "red">$WA$</font> $14:42$ $pC$ <font color = "red">$WA$**(second submission)**</font> $14:44$ $pD$ <font color = "green">$AC$</font> $14:46$ $pE$ <font color = "green">$AC$</font> $14:49$ $pC$ <font color = "red">$WA$**(third submission)**</font> $14:50$ $pC$ <font color = "green">$AC$**(fourth submission)**</font> **總計 :** $19$ $mins$ $\space\space$ <font color = "green">$5$ $AC$</font> <font color = "red">$4$ $WA$</font> # 題目 * **pA 中間數** **難度 : :star:** :::success **題意 :** **給三數 $a$ $b$ $c$** **假如三數有相同的兩數或三數** **輸出 ERROR!** **否則輸出中間數(a > b > c 輸出 b)** **範例輸入 1:** ``` 1 2 3 ``` **範例輸出 1:** ``` 2 ``` **範例輸入 2:** ``` 5 87 2 ``` **範例輸出 2:** ``` 5 ``` ::: :::warning **想法 :** **1.把 $a$ $b$ $c$ 排序 然後輸出b** **2.數學解 ~~通靈~~** $mid = a + b + c - max(a,b,c) - min(a,b,c)$ ::: :::spoiler <font color = "gold">**code(數學解)**</font> ```cpp= #include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if(a == b || b == c || c == a) { cout << "ERROR\n"; } else { cout << a + b + c - max(a, max(b, c)) - min(a, min(b, c)) << '\n'; } } ``` ::: :::info **解題心得 :** **數學解蠻難想的** **但只要有想到大概實作一分鐘(?** ::: * **pB 成績計算進階** **難度 : :star:** :::success **題意 :** **給 $13$ 個 數字 $A_i$ $1\leq i \leq 13$** **$A_1$ ~ $A_{11}$ 是 $11$ 次平時考 $A_{12}\space A_{13}$ 是期中末成績(各$20$ %)** **平時成績扣掉最高的一次$\div10$ 就是最終平常成績($60$ %)** **輸出最後的學期總成績(平常成績$\times 60$ % + 期中末成績$\times 40$ %)** **範例輸入 1:** ``` 60 62 60 34 67 34 81 38 29 10 34 34 12 ``` **範例輸出 1:** ``` 34.88 ``` ::: :::warning **想法 :** **輸入後維護平常考的最大值** ::: :::spoiler <font color = "gold">**code<font color = "red">(WA 60%)</font>**</font> ```cpp= #include <bits/stdc++.h> using namespace std; int main() { cout << fixed << setprecision(2); double ans = 0; int mx = 0; // 平常成績輸入 for(int i = 0; i < 11; i++) { int a; cin >> a; mx = max(mx, a); ans += a; } ans -= mx; ans *= 6; // 期中末輸入 for(int i = 0; i < 2; i++) { int a; cin >> a; ans += a*20; } cout << ans/100 << '\n'; } ``` ::: :::spoiler <font color = "gold">**code<font color = "green">(AC)</font>**</font> ```cpp= #include <bits/stdc++.h> using namespace std; int main() { // cout << fixed << setprecision(2); // 題目沒說要限定到小位數2... double ans = 0; int mx = 0; // 平常成績輸入 for(int i = 0; i < 11; i++) { int a; cin >> a; mx = max(mx, a); ans += a; } ans -= mx; ans *= 6; // 期中末輸入 for(int i = 0; i < 2; i++) { int a; cin >> a; ans += a*20; } cout << ans/100 << '\n'; } ``` ::: :::info **解題心得 :** **下次要看清楚題目...** ::: * **pC 排列數** **難度 : :star2:** :::success **題意 :** **給兩數 $n$ $m$** **求$P_m^n$** **$1 \leq m \leq n \leq 25$** **範例輸入 1:** ``` 15 10 ``` **範例輸出 1:** ``` 10897286400 ``` **範例輸入 2:** ``` 3 2 ``` **範例輸出 2:** ``` 6 ``` ::: :::warning **想法 :** **first : $n!/(n-m)!$** **second : $n\times{(n-1)}...\times{(n-m+1)}$** ::: :::spoiler <font color = "gold">**code<font color = "red">(WA 80%)</font>**</font> ```cpp= #include <bits/stdc++.h> using namespace std; #define ll long long int main() { vector<ll> v(100); v[0] = 1; // 0! = 1 for(int i = 1; i < 50; i++) { v[i] = v[i-1]*i; } int n, m; cin >> n >> m; cout << v[n]/v[n-m+1] << '\n'; } ``` ::: **因為${25}! \approx {10}^{25}$ 然後 $long$ $long$ 只到 ${10}^{18}$** :::spoiler <font color = "gold">**code<font color = "green">(AC)</font>**</font> ```cpp= #include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n, m; cin >> n >> m; ll ans = 1; for(int i = n; i >= n-m+1; i--) { ans *= i; } cout << ans << '\n'; } ``` ::: :::info **解題心得 :** **被數學誤導吃了3次WA...** ::: * **pD 骰子** **難度 : :star:** :::success **題意 :** **給 $n$ 代表接下來會有 $n$ 個數字 $A_i$ ($1 \leq i \leq n$)** **$1 \leq A_i \leq 6$ 代表骰子** **輸出各個骰子點數共出現幾次** Input : ```7 1 2 2 3 4 5 6``` output : ``` 1:* 2:** 3:* 4:* 5:* 6:* ``` ::: :::warning **想法 :** **照題目寫AC** ::: :::spoiler <font color = "gold">**code**</font> ```cpp= #include <bits/stdc++.h> using namespace std; int p[6]; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { int a; cin >> a; p[a-1]++; } for(int i = 1; i <= 6; i++) { cout << i << ':'; // cout << setw(p[i-1]+1) << setfill('*') << '\n'; for(int j = 0; j < p[i-1]; j++) { cout << '*'; } cout << '\n'; } } ``` ::: :::info **解題心得 :** **有用到陣列一點點(假如要秒解的話)** ::: * **pE 聯誼** **難度 : :star:** :::success **題意 :** **給二數 $f$ $m$ 代表女孩跟男孩** **接著會有三種情況 :** **假如 女孩的人數 $\leq$ 男孩的人數 且 男孩的人數為女孩人數的倍數的話** **輸出 Happy** **假如 女孩的人數 $>$ 男孩的人數 且 女孩的人數為男孩人數的倍數的話** **輸出 Sad** **其他可能輸出 (R開頭的單字 我忘了QQ)** **範例輸入 1:** ``` 3 2 ``` **範例輸出 1:** ``` R.... ``` **範例輸入 2:** ``` 9 1 ``` **範例輸出 2:** ``` Sad ``` **範例輸入 3:** ``` 5 10 ``` **範例輸出 3:** ``` Happy ``` ::: :::warning **想法 :** **照題目寫 開3個if** ::: :::spoiler <font color = "gold">**code**</font> ```cpp= #include <bits/stdc++.h> using namespace std; int p[6]; int main() { int a, b; cin >> a >> b; if(a <= b && b % a == 0) { cout << "Happy\n"; } else if(a > b && a % b == 0) { cout << "Sad\n"; } else { cout << "R....\n"; } } ``` ::: :::info **解題心得 :** **水題放在最後有點不尊重ㄛ:)** :::