###### POJ 2739 Sum of Consecutive Prime Numbers

#include<stdio.h>

int isprime(int a)
{
int i;
for(i=2; i*i<=a; i++)
if(a%i==0) return 0;

return 1;
}

int prime[1230];
int main()
{
int i,j,a,b,count;
scanf("%d", &a);
while(a != 0)
{
//算出a以内的素数
j=0;
for(i=2; i<=a; i++)
{
if(isprime(i)) prime[j++]=i;
}
count=0;
j--;
for(;j>=0;j--)
{
i=j;
b=a;
for(;i>=0;i--)
{
b -= prime[i];
if(b==0) //找到了一种表示方法
{
count++;
break;
}
else if(b < 0) break;
}
}
printf("%d\n", count);

scanf("%d", &a);
}

return 0;
}


#### POJ_2739_Sum of Consecutive Prime Numbers(打表)

2013-08-14 10:27:52

#### POJ-2739 Sum of Consecutive Prime Numbers-求一个数满足有多少组递增相加的素数等于该数

2015-08-07 19:31:19

#### 【打表】POJ-2739 Sum of Consecutive Prime Numbers

2014-11-08 11:45:13

#### POJ2739-Sum of Consecutive Prime Numbers

2011年07月29日 6KB 下载

#### POJ - 2739 Sum of Consecutive Prime Numbers（尺取法）

2015-09-16 14:39:15

#### poj-2739-Sum of Consecutive Prime Numbers

2016-03-25 18:58:47

#### Sum of Consecutive Prime Numbers----暴力水题

2017-04-10 15:12:26

#### POJ 2739 E - Sum of Consecutive Prime Numbers 素数打表+尺取法

2016-12-10 20:15:24

#### 北大ACM2739——Sum of Consecutive Prime Numbers

2015-07-08 13:31:23

#### POJ 2739 Sum of Consecutive Prime Numbers（尺取）

2015-08-29 08:25:48

## 不良信息举报

POJ 2739 Sum of Consecutive Prime Numbers