题目链接: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. (三)stm32之串口通信DMA传输完成中断

    一.DMA功能简介 首先唠叨一下DMA的基本概念,DMA的出现大大减轻了CPU的工作量.在硬件系统中,主要由CPU(内核).外设.内存(SRAM).总线等结构组成,数据经常要在内存和外设之间,外设和外 ...

  2. 如何设置DIV水平、垂直居中

    一.水平居中 需要设置两点: 1  设置DIV 的width属性即宽度. 2  设置div的margin-left和margin-right属性即可 代码: <div style="w ...

  3. 如何在Mac OSX上安装xgboost

    听说xgboost效果很不错,于是准备学习下,但是发现大多数资料都是在讲如何在windows或linux下安装xgboost,而且照着官方文档也没有正确的安装好多线程的xgboost.最后还是从the ...

  4. 关于 MySQL LEFT JOIN 你可能需要了解的三点(zhuan)

    http://www.oschina.net/question/89964_65912 ****************************************** 即使你认为自己已对 MyS ...

  5. 转 java int与Integer的区别

    int是java提供的8种原始数据类型之一, Java为每个原始类型提供了封装类,Integer是java为int提供的封装类. int 是基本类型,Integer是引用类型. java.lang.I ...

  6. ObjectMapper处理从远程获取的Object对象

    微服务中从其他服务获取过来的对象,如果从Object强转为自定义的类型会报错,利用ObjectMapper转换. ObjectMapper mapper = new ObjectMapper(); D ...

  7. linux笔记:链接命令,软链接和硬链接

    命令名称:ln功能:生成链接文件命令所在目录:/bin/ln用法:ln [-s] 原文件 目标文件参数:-s 创建软链接(不写此参数则生成硬链接) 软链接:类似windows中的快捷方式.它只是一个链 ...

  8. 【bzoj1040】骑士

    [bzoj1040]骑士 题意 给定一个基环森林,求最大独立集. 分析 其实这是一道一年前做过的题. 只是今天在看bzoj1023的时候突然来了几许兴致,回过头来看一看. 如果对于一棵树的最大独立集, ...

  9. 20145218 《Java程序设计》第01次实验报告

    北京电子科技学院(BESTI)实验报告 课程:Java程序设计 班级:1452 指导教师:娄嘉鹏 实验日期:2016.04.08 实验名称:Java开发环境的熟悉(Linux + Eclipse) 实 ...

  10. 布局两列div等高方法

    一.左右布局,左侧div绝对定位,外div相对定位 <!DOCTYPE html> <html lang="en"> <head> <me ...