题目链接:http://poj.org/problem?id=2739

#include <cstdio>
#include <cstring>
using namespace std;
int method[10001][1300];
int dp[10001];
bool isntprime[10001];
int heap[1300],cnt;
void calprime(){
method[2][0]=1;
dp[2]++;
heap[cnt++]=2;
for(int i=3;i<10001;i+=2){
if(!isntprime[i]){
heap[cnt]=i;
method[i][cnt++]=1;dp[i]++;
for(int j=3;i*j<10001;j+=2){
isntprime[i*j]=true;
}
}
}
}
void caldp(){
for(int i=2;i<10001;i++){
for(int j=0;j<cnt;j++){
if(method[i][j]!=0){
if(j<cnt-1&&i+heap[j+1]<10001){
method[i+heap[j+1]][j+1]+=method[i][j];
dp[i+heap[j+1]]+=method[i][j];
}
}
}
}
}
int main(){
calprime();
caldp();
int n;
while(scanf("%d",&n)==1&&n){
printf("%d\n",dp[n]);
}
return 0;
}

POJ 2739 Sum of Consecutive Prime Numbers 难度:0的更多相关文章

  1. POJ.2739 Sum of Consecutive Prime Numbers(水)

    POJ.2739 Sum of Consecutive Prime Numbers(水) 代码总览 #include <cstdio> #include <cstring> # ...

  2. POJ 2739 Sum of Consecutive Prime Numbers(素数)

    POJ 2739 Sum of Consecutive Prime Numbers(素数) http://poj.org/problem? id=2739 题意: 给你一个10000以内的自然数X.然 ...

  3. poj 2739 Sum of Consecutive Prime Numbers 素数 读题 难度:0

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19697 ...

  4. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  5. POJ 2739 Sum of Consecutive Prime Numbers(尺取法)

    题目链接: 传送门 Sum of Consecutive Prime Numbers Time Limit: 1000MS     Memory Limit: 65536K Description S ...

  6. POJ 2739 Sum of Consecutive Prime Numbers( *【素数存表】+暴力枚举 )

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19895 ...

  7. POJ 2739 Sum of Consecutive Prime Numbers【素数打表】

    解题思路:给定一个数,判定它由几个连续的素数构成,输出这样的种数 用的筛法素数打表 Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memo ...

  8. poj 2739 Sum of Consecutive Prime Numbers 小结

     Description Some positive integers can be represented by a sum of one or more consecutive prime num ...

  9. poj 2739 Sum of Consecutive Prime Numbers 尺取法

    Time Limit: 1000MS   Memory Limit: 65536K Description Some positive integers can be represented by a ...

随机推荐

  1. [转载] 淘宝内部分享:怎么跳出MySQL的10个大坑(上)

    原文: http://mp.weixin.qq.com/s?__biz=MzAxNjAzMTQyMA==&mid=209773318&idx=1&sn=e9600d3db80b ...

  2. [转载] Docker网络原则入门:EXPOSE,-p,-P,-link

    原文: http://dockone.io/article/455 如果你已经构建了一些多容器的应用程序,那么肯定需要定义一些网络规则来设置容器间的通信.有多种方式可以实现:可以通过--expose参 ...

  3. js输出26个字母两种方法(js fromCharCode的使用)

    方法一 var character = new Array("A","B","C","D","E", ...

  4. mysql 权限控制

    1.mysql的权限是,从某处来的用户对某对象的权限. 2.mysql的权限采用白名单策略,指定用户能做什么,没有指定的都不能做. 3.权限校验分成两个步骤: a.能不能连接,检查从哪里来,用户名和密 ...

  5. Mac 实用工具与问题解决

    1.在dock上方的一长溜,被我拖成个方块了 删掉里面的字符,然后按esc 即可! 2.FIT输入法(Fun Input Toy),是苹果操作系统OS X上的免费中文输入法,支持全拼/双拼/全双混拼, ...

  6. 转:一个Sqrt函数引发的血案

    转自:http://www.cnblogs.com/pkuoliver/archive/2010/10/06/1844725.html 源码下载地址:http://diducoder.com/sotr ...

  7. html frames

    http://blog.sina.com.cn/s/blog_67697189010116o0.html *********************************************** ...

  8. Struts2文件上传

    1  在Struts2中上传文件需要 commons-fileupload-1.2.1.jar.commons-io-1.3.2.jar 这两个包. 2  确认页面form表单上的提交方式为POST, ...

  9. IE浏览器GET传参后台乱码

    ie里面 get传递的字符串 为 gb2312  ,后台用的是utf-8类型  所以用 POST传递字符串到后端 否则进行js参数转码 encodeURI(""); 后端解码

  10. Java多线程同步的方法

    一 synchronized关键字 1.synchronized实现原理: ---基于对象监视器(锁) java中所有对象都自动含有单一的锁,JVM负责跟踪对象被加锁的次数.如果一个对象被解锁,其计数 ...