#include<iostream> #include<cmath> #include<algorithm> #include<string.h.> using namespace std; /*2909 Accepted 268K 16MS C++ 1137B 2011-06-13 22:36:09*/ /*水题 筛素数 东北赛结束了,虽然1004那个素论做的有点不给力,但是我已经爱上素论了*/ #define N (int)(pow((double)2, (double)15) + 1) bool isprime[258*129]; int prime[4000]; int getprime(int n) { int i, j, k = 0; int s, e = (int)(sqrt(n*1.00)+1); memset(isprime, true, sizeof(isprime)); isprime[0] = isprime[1] = false; prime[k++] = 2; for(i=4; i<n; i+=2) isprime[i] = false; for(i=3; i<e; i+=2) { if(isprime[i]) { prime[k++] = i; for(s=i*2, j=i*i; j<n; j+=s) isprime[j] = false; } } for( ; i<n; i+=2) { if(isprime[i]) prime[k++] = i; } return k; } int solve(int n, int k) { int ret = 0; for(int i=0; i < k && prime[i] <= (int)(n/2); i++) { if( isprime[n-prime[i]] ) { ret++; } } return ret; } int main() { int n, k = getprime(N); printf("%d/n", k); while(scanf("%d", &n)!=EOF) { if(n==0) break; int ret = solve(n, k); printf("%d/n", ret); } return 0; }