呃呃呃。很水的一道题,没什么说的,打表,然后筛出来符合条件的解就可以了,多多借助变量之间特殊的关系进行表示会达到简化的目的。
# include<cstdio>
# include<iostream>
# include<cstring>
using namespace std;
# define MAX 10000
int hash[MAX+10];
void dabiao()
{
memset(hash,0,sizeof(hash));
hash[0] = 1;
hash[1] = 1;
for ( int i = 2;i < MAX;i++ )
{
//if (i > MAX/i ) continue;//如果数据大的话,就要这样处理,防止爆int
if ( !hash[i] )
{
for ( int j = i*i;j < MAX;j+=i )
{
hash[j] = 1;
}
}
}
}
int main(void)
{
dabiao();
int n;
while ( (cin>>n)&&n )
{
int ans = 0;
for ( int i = 2;i < n/2;i++ )
{
if ( hash[i]==0 && hash[n-i]==0 )ans++;
}
cout<<ans<<endl;
//dabiao();
}
return 0;
}