Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5296 Accepted Submission(s): 1393
就是筛选法打表,代码如下:
#include<stdio.h> #include<string.h> #include<math.h> int a[1001000]={0}; int sum[1002]; int main() { int n,i,j,m; scanf("%d",&n); for(i=1;i<500500;i++)//筛选法打表 for(j=2*i;j<1001000;j+=i) a[j]+=i; for(i=1;i<1001000;i++)//对1000以内的能够取到数再次打表标记 if(a[i]<=1000) sum[a[i]]=1; while(n--) { scanf("%d",&m); if(sum[m]) puts("no");//puts自动添加换行符 else puts("yes"); } return 0; }
原文地址:http://blog.csdn.net/ice_alone/article/details/38331023