今天校內舉辦學科能競的校內賽
美其名是要初選去比區賽的人選
但實際上題目水到根本沒有可以鑑別度可以選人
如果這樣都能篩到人 那我只能說這年頭教育有點慘淡

這次的題目都很簡單啦 就考驗基本的 IO、loop 跟 condition 而已
只有 P4 會需要用 ASCII 而已
反正四題都水題
以下題目

# P1

見輸出入說明

# Input

每次單筆輸入 總共一行
給予一非負整數 n (n 沒給上限)

# Output

輸出一行
輸出 n 之所有因數

Solution ```=cpp #include #define IO ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

signed main(){
int n;cin>>n;
for (int i=1;i<n+1;i++) if (!(n%i)) cout<<i<<" ";
return 0;
}

</details>

### P2

有一種數稱之為Armstrong數,其定義為各位數字的三方相加之和等於其原本的數
E.g. 153=1<sup>3</sup>+3<sup>3</sup>+5<sup>3</sup>=1+27+125

#### Input

==No input==

#### Output

輸出所有三位數Armstrong數

<details>
  <summary><font color=#AA2C50>Solution</font></summary>
```cpp
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

int n,tmp,sum;

signed main(){
    for (int i=100;i<1000;i++){
        sum=0;n=i;
        sum+=(n%10)*(n%10)*(n%10);n/=10;
        sum+=(n%10)*(n%10)*(n%10);n/=10;
        sum+=n*n*n;
        if (sum==i) cout<<i<<' ';
    }
}

# P3

見輸出入說明

# Input

每次單筆輸入
輸入只有一行
輸入 n 保證為數字串

# Output

輸出一行
判斷輸入是否回文

  1. 若為真:輸出 [n] is a palindrome.
  2. 若為假:輸出 [n] is not a palindrome.
Solution
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

signed main(){
    string s;
    int flag=0;
    cin>>s;
    for (int i=0;i<s.length();i++){
        if (s[i]!=s[s.length()-i-1]){
            cout<<s<<" is not a palindrome."<<endl;
            flag++;
            break;
        }
    }
    if (!flag) cout<<s<<" is a palindrome."<<endl;
}

# P4

見輸出入說明

# Input

每次單筆輸入
輸入一行字串 (包含空格字元)(筆者在作答時忽略這點,直接使用 cin,故這題應該是噴掉了,正解應該使用 getline)
並保證內容皆為合法字元

# Output

輸出字串中各個英文字母的數量
僅輸出字串中有的英文字母即可 沒有出現即不用輸出
大小寫均計算為同一字母

Solution
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

signed main(){
    string s;
    int ct[26]={0};
    getline(cin,s);
    for (int i=0;i<s.length();i++){
        if (s[i]>=65&&s[i]<=90) ct[s[i]-65]++;
        if (s[i]>=97&&s[i]<=122) ct[s[i]-97]++;
    }
    for (int j=0;j<26;j++){
        if (ct[j]) cout<<(char)(j+65)<<" or "<<(char)(j+97)<<" : "<<ct[j]<<"個"<<endl;
    }
}

# 結論

基本上這次都還蠻水的
撇除掉 P4 我在耍腦忽略可能有空格忘記用 getline
其他三題都是學程式前幾堂一定會被拿出來的模板題
水到一個不行
粗心錯真的是我不應該
不過沒意外我應該還是會進培訓啦
就等結果出來跟看區賽如何吧