标签:turned paper output eve pac esc central ext page
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 930 Accepted Submission(s): 491
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 int t; 8 bool check[3000010]; 9 int num[1000010]; 10 void Eratosthenes(){ 11 check[0]=1; 12 check[1]=1; 13 for(int i=2;i<=sqrt(3000010);i++) 14 if(!check[i]) 15 for(int j=2*i;j<=3000010;j+=i) check[j]=1; 16 } 17 int main(){ 18 scanf("%d",&t); 19 Eratosthenes(); 20 for(int i=1;i<=1000000;i++) 21 if(check[3*i+7]) num[i]=num[i-1]; 22 else num[i]=num[i-1]+1; 23 int a; 24 for(int i=1;i<=t;i++){ 25 scanf("%d",&a); 26 printf("%d\n",num[a]); 27 } 28 return 0; 29 }
标签:turned paper output eve pac esc central ext page
原文地址:http://www.cnblogs.com/sdfzxh/p/7148177.html