zoukankan      html  css  js  c++  java
  • 杭电2098--分拆素数和

    分拆素数和

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 25994    Accepted Submission(s): 11374


    Problem Description
    把一个偶数拆成两个不同素数的和,有几种拆法呢?
     
    Input
    输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。
     
    Output
    对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。
     
    Sample Input
    30 26 0
     
    Sample Output
    3 2
     
    Source
    //不要超时,打表;
     
     1 #include<stdio.h>
     2 const int N = 10000;
     3 int biao[10010];
     4 int main()
     5 {
     6     int i;
     7     for(i=2;i<N;i++)
     8     biao[i]=0;
     9     for(i=2;i<N;i++)
    10     {
    11         if(!biao[i])
    12         {
    13             int j;
    14             for(j=2*i;j<N;j+=i)
    15             biao[j]=1;
    16         }
    17     }
    18     
    19     int n;
    20     while(~scanf("%d",&n)&&n)
    21     {
    22         int total=0;
    23         for(i=2;i<n/2;i++)
    24         {
    25             if(!biao[i]&&!biao[n-i])
    26             total++;
    27         }
    28         printf("%d
    ",total);
    29     }
    30     return 0;
    31 }
     
  • 相关阅读:
    auto-sklearn案例解析二
    auto-sklearn案例解析二
    auto-sklearn案例解析一
    auto-sklearn案例解析一
    auto-sklearn简介
    auto-sklearn简介
    auto-sklearn手册
    auto-sklearn手册
    观念
    JDBC总结
  • 原文地址:https://www.cnblogs.com/soTired/p/4574456.html
Copyright © 2011-2022 走看看