poj2739
来源:互联网 发布:优盘安装ubuntu 编辑:程序博客网 时间:2024/05/16 05:47
// poj2739.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <math.h>
int prime(int n)
{
int i;
if(n ==1 )
return 0;
if(n == 2)
return 1;
for(i=2;i <= (int)sqrt(n);i++)
if(n % i == 0)
return 0;
return 1;
}
int count(int n)
{
int cn = 0;
int i,j;
int sum=0;
for(j=2;j<=n;j++)
{
sum = 0;
if(prime(j)==1) //!!
{
for(i=j;i<=n;i++)
{
if(prime(i))
sum += i;
if(sum > n)
break;
if(sum == n)
{
cn++;
break;
}
}
}
}
return cn;
}
int main()
{
int c=0;
int n;
int i;
scanf("%d",&n);
if(n == 0)
return 0;
while(n !=0)
{
c = count(n);
printf("%d/n",c);
scanf("%d",&n);
}
return 0;
}
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- POJ2739
- POJ2739
- POJ2739
- poj2739
- poj2739
- POJ2739
- poj2739
- poj2739
- poj2739
- ural 1025 Democracy in Danger
- socket
- 类的构造函数及构造函数重载
- poj2262
- php 正则表达式(模式修正符)
- poj2739
- aStyle配置 备忘
- 类的静态构造函数
- PHP5的正则表达式
- android:利用DatabaseUtils.InsertHelper提高insert速度
- 新的一年开始了,给自己今年的技术之路定下目标与实现细则。
- 新年快乐
- sqlserver, mysql
- visual studio 调试需要pdb文件