标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5277 Accepted Submission(s):
2022
点我
1 #include <iostream> 2 using namespace std; 3 int a[32765]; 4 int isprime() 5 { 6 int i,k,x; 7 for(i=2;i<32765;i++) 8 { 9 for(k=2;k<=i/2;k++) 10 { 11 if(i%k==0) 12 break; 13 } 14 if(k==i/2+1) 15 a[i]=1; 16 else 17 a[i]=0; 18 } 19 return 0; 20 } 21 int main() 22 { 23 int x,i,j,count=0; 24 isprime(); 25 while(cin>>x&&x) 26 { 27 count=0; 28 for(i=j=x/2;i>=2;i--,j++) 29 { 30 if(a[i]&&a[j]) 31 { 32 count++; 33 } 34 } 35 cout<<count<<endl; 36 } 37 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4681245.html