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;
}
相关文章
|
6月前
POJ-2245-Lotto
POJ-2245-Lotto
28 0
|
6月前
|
算法
Wormholes—POJ3259
Wormholes—POJ3259
|
6月前
|
算法 数据建模
Poj 3169(差分约束系统)
Poj 3169(差分约束系统)
34 0
|
人工智能 机器学习/深度学习
poj 1455
Description n participants of > sit around the table. Each minute one pair of neighbors can change their places.
618 0
|
JavaScript
POJ 2487 Stamps
Description Background Everybody hates Raymond. He’s the largest stamp collector on planet earth and because of that he always makes fun of all the others at the stamp collector parties.
1064 0