poj2739
来源:互联网 发布:怎样提高淘宝买家信用 编辑:程序博客网 时间:2024/04/29 12:48
#include<iostream>
#include<string.h>
using namespace std;
int prime[1500];
int total=0;
int main()
{
int a;
memset(prime,0,1500);
prime[0]=2;
total=1;
for(int i=3;i<=10000;i++)
{
bool flag=true;
for(int j=0;j<total;j++)
{
if(i%prime[j]==0)
{
flag=false;
break;
}
}
if(flag)
{
prime[total++]=i;
}
}
cin>>a;
while(a!=0)
{
int ans=0;
for(int i=0;i<total;i++)
{
int cnt=0;
int x=i;
while(cnt<a)
{
cnt+=prime[x];
if(cnt==a)
{
ans++;
break;
}
else
x++;
}
}
cout<<ans<<endl;
cin>>a;
}
return 0;
}
#include<string.h>
using namespace std;
int prime[1500];
int total=0;
int main()
{
int a;
memset(prime,0,1500);
prime[0]=2;
total=1;
for(int i=3;i<=10000;i++)
{
bool flag=true;
for(int j=0;j<total;j++)
{
if(i%prime[j]==0)
{
flag=false;
break;
}
}
if(flag)
{
prime[total++]=i;
}
}
cin>>a;
while(a!=0)
{
int ans=0;
for(int i=0;i<total;i++)
{
int cnt=0;
int x=i;
while(cnt<a)
{
cnt+=prime[x];
if(cnt==a)
{
ans++;
break;
}
else
x++;
}
}
cout<<ans<<endl;
cin>>a;
}
return 0;
}
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- poj2739
- POJ2739
- POJ2739
- POJ2739
- poj2739
- poj2739
- POJ2739
- poj2739
- poj2739
- poj2739
- SAP ERP SD-Output Tax和Country的相关配置
- PE 文件格之资源
- mondrian配置XMLA的例子
- Visual Studio 单元测试之六---UI界面测试 (转)
- 分享一些最近在看的电子书
- poj2739
- android webview 和 js交互
- (->*)
- 数据添加(jquery)
- 图数据库比较 Graph Database Comparison Chart
- eclipse导出可执行的jar包
- POJ 1094 Sorting It All Out
- mondrian 配置XMLA例子2
- 你需要知道的 16 个 Linux 服务器监控命令