标签:blog os io for div log amp sp on
水,用来熟悉内容
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; const int Max=10050; bool prime[Max+10]; int main(){ memset(prime,true,sizeof(prime)); prime[0]=prime[1]=false; int e=(int)sqrt(1.0*Max); for(int i=2;i<=e;i++){ if(prime[i]){ for(int j=i+i;j<=Max;j+=i) prime[j]=false; } } int n; while(scanf("%d",&n),n){ int c=0; int lim; if((n%2)==0) lim=n/2; else lim=n/2+1; for(int i=2;i<=lim;i++) if(prime[i]&&prime[n-i]){ if(i!=n-i) c++; } printf("%d\n",c); } return 0; }
标签:blog os io for div log amp sp on
原文地址:http://www.cnblogs.com/jie-dcai/p/3940247.html