Super Prime

Super Prime

Time Limit: 5000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

We all know, prime is a kind of special number which has no other factors except of 1 and itself.
2,3,5,7,11,13,17,19,23,29 are the top 20 primes.
Now there is a new question about prime:
We call a prime as super prime when and only when which can be represented as the sum of multiple continuous primes. For example: 5=2+3, so 5 is a super prime.
Please program to judge whether a number is a super prime or not.

输入

The first line is an integer T (T<=1000), and then T lines follow.
There is only one positive integer 
N(1

输出

For each case you should output the case number first, and then the word "yes" if the integer N is a super prime, and you should output "no" otherwise.

示例输入

3
5
7
8

示例输出

Case 1: yes
Case 2: no
Case 3: no

提示

 

来源

2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛(热身赛)
#include 
#include
#include
#include
using namespace std;
bool flag1[100010];
bool flag2[100010];
int prime[20000],k;
void getprime()
{
    memset(flag1,0,sizeof(flag1));
    flag1[1]=1;
    int i,j;

    for(i=2;i<=100000;i++)
    {
        if(!flag1[i])
        {
            prime[++k]=i;
        }
            for(j=1;j<=k&&i*prime[j]<=100000;j++)      //素数筛;
            {
                flag1[i*prime[j]]=1;
                if(i%prime[j]==0)
                break;
            }

    }


}
void super()
{
    int g;

    for(int i=1;i>t)
   {
       l=0;
       while(t--)
       {
           cin>>n;
           printf("Case %d: ",++l);
           if(flag2[n])
           printf("yes\n");
           else
           printf("no\n");
       }
   }
    return 0;
}


你可能感兴趣的:(水题)