#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int n, len= 0;
bool visite[1<<15];
int p[1<<15];
void prim()
{
memset( visite, false, sizeof(visite) );
for( int i= 2; i<= 1<<15; ++i )
if( !visite[i] )
{
p[len++]= i;
int t= i+ i;
while( t<= 1<< 15 )
{
visite[t]= true;
t+= i;
}
}
}
bool binary( int value )
{
int left= 0, right= len;
while( left+ 1< right )
{
int m= (left+ right)>> 1;
if( value< p[m] ) right= m;
else if( value> p[m] ) left= m;
else return true;
}
return false;
}
int main()
{
prim();
while( scanf("%d",&n), n!= 0 )
{
int num= 0;
for( int i= 0; p[i]* 2<= n; ++i )
if( binary(n-p[i]) ) num++;
printf("%d\n", num );
}
return 0;
}
posted on 2008-12-24 20:57
Darren 阅读(239)
评论(0) 编辑 收藏 引用