2013=7=22

Problem Description 把一个偶数拆成两个不同素数的和,有几种拆法呢?  

Input 输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。  

Output 对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。  

Sample Input 30 26 0  

Sample Output 3 2   **************************************** **************************************************************************

 

#include <iostream>

using namespace std;

#define N 10000

int bz[N]={1,1,0,0,1,0};    

void init()

{

int i,j;

for(i=2;i<=N;i++)

for(j=2;i*j<=N;j++)

bz[i*j]=1;

}

int main()

{     int n,i,s;    

init();   

  while(cin>>n,n)  

   {      

   s=0;    

     for(i=2;i<n/2;i++)     

    if(bz[i]==0&&bz[n-i]==0)        s++;

    cout<<s<<endl;       

}    

}

posted @ 2013-07-23 23:20  博园少主  阅读(132)  评论(0编辑  收藏  举报