6 solutions

  • 0
    @ 2023-3-14 20:59:24

    c 用的for循环

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
    	int q,m;
    	int z;
    	int i,j,k;
    	int isp=1;
    	scanf("%d",&q);
    	int a[q];
    	for(i=0;i<q;i++){
    		scanf("%d",&m);
    		a[i]=m;
    		
    	}
    	for(j=0;j<q;j++){
    		
    		z=a[j];
    		for(k=2;k<sqrt(z);k++){
    			if(z%k==0){
    				isp=0;
    				break;
    			}
    		
    			
    		}
    		if(isp==1){
    			printf("Yes\n");
    		}
    		if(isp==0){
    			printf("No\n");
    			isp=1;
    		}
    	}
    	return 0;
    	
    }
    

    Information

    ID
    43
    Time
    5000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    1260
    Accepted
    251
    Uploaded By