Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
打表咋过不到?#include<iostream> #include<algorithm> using namespace std; #define N 10000 bool a[10000]; long p[10000] ; void creat(void) { long i,num; memset(a, true, sizeof(a)); num = 0; for(i = 2; i < N; ++i) { if(a[i]) p[num++] = i; for(int j = 0; (j<num && i*p[j]<N); ++j) { a[i*p[j]] = false; if(i%p[j]==0) break; } } } int main() { long k,ans; long n,s,b; creat(); while(cin>>n&&n!=0) { k=0; ans=0; while(1) { s=p[k]; b=n-s; if(s>b) break; if(a[b]) { ans++; k++; } else k++; } cout<<ans<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator