#27683: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
b513. 判斷質數-商競103 -- 103學年度商業類程式設計競賽模擬題 | From: [27.105.52.161] | 發表日期 : 2021-10-23 14:27

#include <iostream>
#include <cmath>
using namespace std;

int main(){
int n, x, root;
bool prime;
cin >> n;
while (n--){
cin >> x;
root=sqrt(x);
prime=true;
for (int i=2; i<=root; i++){
if (x%i==0){
prime=false;
}
}
prime ? cout <<"Y\n" : cout <<"N\n";
}
}
 
ZeroJudge Forum