标签:
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
#include<bits/stdc++.h> using namespace std; #define ll __int64 #define esp 0.00000000001 const int N=1e3+10,M=1e6+10,inf=1e9+10,mod=1000000007; int prime(int n) { if(n<=1) return 0; if(n==2) return 1; if(n%2==0) return 0; int k, upperBound=n/2; for(k=3; k<=upperBound; k+=2) { upperBound=n/k; if(n%k==0) return 0; } return 1; } int main() { int x,y,z,i,t; int T; scanf("%d",&T); while(T--) { scanf("%d",&x); if(x==4) printf("2\n"); else if(prime(x)) printf("%d\n",x-1); else printf("0\n"); } return 0; }
hdu 5391 Zball in Tina Town 威尔逊定理 数学
标签:
原文地址:http://www.cnblogs.com/jhz033/p/5687864.html