Try   HackMD

前言

高一基礎程式設計期末考

Scoreboard

scoreboard

Scoreboard

考試過程

心態

一開始本來打算從

pA 寫到
pE

結果
pA
的題敘太長 & 我看不懂

所以就跳
pE
解了

然後深綠被搶了兩題:D

解題順序

pEpDpCpBpA

14:27
pE
AC

14:28
pD
AC

14:31
pC
AC

14:33
pB
AC

14:37
pA
WA

14:38
pA
AC(second submission)

總計 :

11
mins
  
5
AC
 
1
WA

題目

pA 可憐哪

難度 :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題意 :
給一數

N
有一值
poor_value
會隨著
N
而變動

規則如下 :

  • 假如
    N24
    poor_value
    + 1
  • 如果
    25N3×24
    poor_value
    + 2
  • 如果
    3×24<N7×24
    poor_value
    + 3
  • 如果
    7×24<N
    poor_value
    + 5

接著根據

poor_value的值輸出

  • 如果
    poor_value24
    輸出 "Poor~~"(不含引號)
  • 如果
    25poor_value60
    輸出 "Poor You!"(不含引號)
  • 如果
    61poor_value100
    輸出 "Pathetic!!"(不含引號)
  • 如果
    101poor_value200
    輸出 "Ko lan na~~~"(不含引號)
  • 如果
    201poor_value
    輸出 "Nonsense post!!!"(不含引號)

範例輸入1 :

2

範例輸出1 :

Poor~~

範例輸入2 :

300

範例輸出2 :

Nonsense post!!!!

想法 :
簡單題if else題
沒給

N 範圍 但感覺
poor_value
值會溢位

所以我有開long long


code
#include <iostream> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; long long pov = 0; if(n <= 24) { pov = n; } else if(n <= 3*24) { pov = 24 + (n-24)*(2); } else if(n <= 7*24) { pov = 24 + (2*24)*(2) + (n-3*24)*(3); } else { pov = 24 + (2*24)*(2) + (4*24)*(3) + (n-7*24)*(5); } if(pov <= 24) { cout << "Poor~~\n"; } else if(pov <= 60) { cout << "Poor You!\n"; } else if(pov <= 100) { cout << "Pathetic!!\n"; } else if(pov <= 200) { cout << "Ko lan na~~~\n"; } else { cout << "Nonsense post!!!!\n"; } }

解題心得 :
放了一張韓國瑜帥臉害我看很久題敘:(

pB 小蘿莉的數學家教B

難度 :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題意 :
給二數

B
H

1B,H106

代表著平行四邊形的底與高
畫平行四邊形及輸出相關資訊
格式請見範例輸出

範例輸入 :

4 5

範例輸出 :

****
 ****
  ****
   ****
    ****
Height: 5
Base: 4
Area: 5*4=20

想法 :
簡單實作題
但要小心

B×H1012
要開long long


code
#include <iostream> using namespace std; signed main() { int b, h; cin >> b >> h; for(int i = 0; i < h; i++) { for(int j = 0; j < i; j++) { cout << ' '; } for(int j = 0; j < b; j++) { cout << '*'; } cout << '\n'; } cout << "Height: " << h << '\n'; cout << "Base: " << b << '\n'; cout << "Area: " << h << '*' << b << '=' << (long long)h*b << '\n'; }

解題心得 :
考的時候總感覺我這題寫很慢
結果看了一下時間
好像也才

2 minutes
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

pC 數字方塊

難度 :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題意 :
給一數

N
要求輸出
N×N
的方格

格式請見範例輸出

範例輸入 :

4

範例輸出 :

1234
2343
3432
4321

想法 :
簡單巢狀題
但我偏偏挑了一個難實作的解法XD


code
  1. 一般解法
#include <iostream> using namespace std; int main() { int n; cin >> n; for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) { cout << j; } // n-i+1現場跑測資然後再通靈就行 for(int j = n-1; j >= n-i+1; j--) { cout << j; } cout << '\n'; } }
  1. 我那時候的解法 (看看就行)
#include <iostream> using namespace std; int main() { int n; cin >> n; for(int i = 1; i <= n; i++) { int id = i, t = 0; int e = 1; while(t != n) { if(id==n) { e = -1; } cout << id; id += e; t++; } cout << '\n'; } }

解題心得 :
那時候把這題想太難了XD

pD 化簡分數

難度 :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題意 :
給二數

P
Q
代表 分子與分母

輸出最簡分數即可
格式請見範例輸出

範例輸入 :

2 4

範例輸出 :

1 / 2 

想法 :
題目沒給

P
Q
範圍 所以不開long long :D

簡單GCD題


code
  1. 函式解法
#include <iostream> #include <algorithm> // 要用__gcd的話記得要導入這個標頭檔 // #include <bits/stdc++.h> 或者這個 using namespace std; int main() { int p, q; cin >> p >> q; int g = __gcd(p, q); cout << p/g << " / " << q/g << '\n'; }
  1. 輾轉相除法
#include <iostream> using namespace std; int main() { int p, q; cin >> p >> q; int a = p, b = q; // 記得要先把p q存起來or複製 // 不然輾轉相除法會動到原本的值 int g; while(a != 0){ g = a; a = b % a; b = g; } cout << p/g << " / " << q/g << '\n'; }

解題心得 :
之前有做過p, q為負數的
結果這題沒有 好水XD
但這題的難度對新手來說算難了
畢竟沒有人會閒到去背輾轉相除法吧 LOL

pE 伸縮乘法表

難度 :

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

題意 :
給二數

N
M
代表著乘法表的列與行數

按照格式輸出乘法表即可
1N,M1000

範例輸入 :

3 4

範例輸出 :

1*1=1 1*2=2 1*3=3 1*4=4 
2*1=2 2*2=4 2*3=6 2*4=8 
3*1=3 3*2=6 3*3=9 3*4=12 

當然每個等式的最後都有一個空格!

想法 :
巢狀迴圈基礎題 + 判斷

N×M106
所以不用開long long


code
#include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cout << i << '*' << j << '=' << i*j << ' '; } cout << '\n'; } }

解題心得 :
實作起來沒有很困難
水題

總結

這次考試雖然考的範圍比較廣
但好像比較簡單(?
至少我破台的時間有變快ㄏㄏ

最後放一張芙莉蓮 慶祝大家資訊一百分:D
希望大家能喜歡資訊這項學科

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →