标签:
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 492 Accepted Submission(s):
184
#include<stdio.h> #include<string.h> #define MAX 10010 int su[MAX]; void prime() { int i,j; memset(su,0,sizeof(su)); for(i=2;i<MAX;i++) { if(!su[i]) { for(j=i*2;j<MAX;j+=i) su[j]=1; } } su[1]=1; } int main() { int t,n,m,j,i; scanf("%d",&t); prime(); while(t--) { scanf("%d",&n); for(i=n+1;i<MAX;i++) { if(su[i]==0) { printf("%d\n",i); break; } } } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4694580.html