ayf049 edited 1 月前

#include<stdio.h>
#include<math.h>

//判断 
int isPri(unsigned int num) {
    if(num<=1||num%2==0||num%3==0||num%5==0||num%7==0)return 0;
    if(num==2||num==3)return 1;
    for(unsigned int i=5;i*i<=num;i+=6){
        if(num%i==0||num%(i+2)==0)return 0;
    }
    return 1;
}

int main(){
    unsigned int num[10000000];
//输入 
    int j=0;
    while(scanf("%u", &num[j])!= EOF){
        j++;
    }
//输出 
    for(int k=0;k<j;k++){
        if(isPri(num[k])){
            printf("YES");
            }
        else{
            printf("NO");
            }
		if(k!=j-1){
            printf("\n");}}
    return 0;
}

Comments