标签:
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 534 Accepted Submission(s):
203
1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 using namespace std; 5 int sieve[10010]; 6 void is_prime() 7 { 8 memset(sieve, 0, sizeof(sieve)); 9 for(int i = 2; i<10010; i++) 10 { 11 if(sieve[i] == 0) 12 { 13 for(int j = 2 * i; j<10010; j+=i) 14 sieve[j]=1; 15 } 16 } 17 } 18 int main() 19 { 20 int m, t, i; 21 scanf("%d", &t); 22 is_prime(); 23 while(t--) 24 { 25 scanf("%d", &m); 26 for(i=m+1; i<10010; i++) 27 if(sieve[i]==0) 28 break; 29 printf("%d\n", i); 30 } 31 return 0; 32 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4695006.html