#36615: Ans


yp11151230@yphs.tp.edu.tw (710-43蔡亞儒)

學校 : 臺北市私立延平高級中學
編號 : 197211
來源 : [203.72.178.1]
最後登入時間 :
2023-06-14 17:43:23
b513. 判斷質數-商競103 -- 103學年度商業類程式設計競賽模擬題 | From: [203.72.178.1] | 發表日期 : 2023-07-28 14:18

#include <bits/stdc++.h>

using namespace std;

int main(){
	int a,x,k;
	while(cin>>a){
		for(int i=0;i<a;i++){
			cin>>x;
			int flag=1;
			for(int j=2;j<=sqrt(x);j+=(j==2?1:2)){
				if(x%j==0){
					flag=0;
					break;
				}
			}
		if(flag==0) cout<<"N"<<endl;
		else cout<<"Y"<<endl;
		}
		
	}
	
	
	return 0;
}
 
ZeroJudge Forum