#46090: thsi is ej


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    while (n--){
        int a;
        cin>>a;
        bool isPrime=true; // 設立一個布林值判斷它是否是質數(並且預設為true)
        if (a<2){ // 如果輸入的數字小於2,則不是質數
            isPrime=false;
        }
        else{
            for(int i=2;i*i<=a;i++){ // 從2開始,到a的平方根,每次加1
                if (a%i==0){ // 如果a能被i整除,則不是質數
                    isPrime=false; // 將isPrime設為false
                    break;
                }
            }
        }
        if (isPrime) // 如果isPrime為true,則輸出Y
            cout<<"Y"<<endl;
        else // 如果isPrime為false,則輸出N
            cout<<"N"<<endl;
    }
    return 0;
}
#46091: Re: thsi is ej


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45

yeah I don't know what im typing about