poj 2909

简介:
#include <iostream>
#define MAXN 1<<15

using namespace std;

int prime[MAXN];

//为0代表是素数
int findPrime()
{
    //先打出素数表
    prime[0]=prime[1]=1;
    int i,j;
    for(i=2;i<MAXN;i++)
    {
        if(prime[i]==0)
        {
            for(j=2*i;j<MAXN;j+=i)
                prime[j]=1;
        }
    }

    return 0;
}

int main() {

    //freopen("input.txt","r",stdin);

    findPrime();

    int n;
    while ( cin>>n ,n ) {
        int count = 0;
        for(int i=2;i<=n/2;++i) {
            if( !prime[i] && !prime[n-i] )
                count++;
        }
        cout<<count<<endl;
    }

    return 0;
}
相关文章
|
8月前
POJ-2245-Lotto
POJ-2245-Lotto
42 0
POJ 1012 Joseph
Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 53862   Accepted: 20551 Description The Joseph's problem is notoriously known.
846 0
poj 3664
http://poj.org/problem?id=3664 进行两轮选举,第一轮选前n进入第二轮,第二轮选最高   #include #include using namespace std; struct vote { int a,b; int c; ...
742 0
POJ 2262 Goldbach&#39;s Conjecture
Problem Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the foll...
1019 0
|
存储 索引
|
测试技术