zoukankan      html  css  js  c++  java
  • 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;       

    }    

    }

  • 相关阅读:
    codevs 3049 舞蹈家怀特先生
    洛谷P2530 [SHOI2001]化工厂装箱员
    洛谷P2736 “破锣摇滚”乐队 Raucous Rockers
    Phalanx
    Treats for the Cows
    Very Simple Problem
    Alice and Bob
    FatMouse and Cheese
    Tickets
    Piggy-Bank
  • 原文地址:https://www.cnblogs.com/wc1903036673/p/3209666.html
Copyright © 2011-2022 走看看