Ignatius and the Princess III

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 16122    Accepted Submission(s): 11371

Problem Description
"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.



"The second problem is, given an positive integer N, we define an equation like this:

  N=a[1]+a[2]+a[3]+...+a[m];

  a[i]>0,1<=m<=N;

My question is how many different equations you can find for a given N.

For example, assume N is 4, we can find:

  4 = 4;

  4 = 3 + 1;

  4 = 2 + 2;

  4 = 2 + 1 + 1;

  4 = 1 + 1 + 1 + 1;

so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"
 
Input
The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.
 
Output
For each test case, you have to output a line contains an integer P which indicate the different equations you have found.
 
Sample Input
4
10
20
 
Sample Output
5
42
627

/*#include<stdio.h>
#include<string.h>
int dp[1000][1000],n;
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(dp,0,sizeof(dp));
for(int i=1;i<1000;i++)
dp[i][1]=dp[1][i]=1;
for(int i=2;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i>j) dp[i][j]=dp[i-j][j]+dp[i][j-1];
else if(i==j) dp[i][j]=dp[i][j-1]+1;
else dp[i][j]=dp[i][i];
}
}
printf("%d\n",dp[n][n]);
}
return 0;
}*/
#include<stdio.h>
#include<string.h>
int dp[1200];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(dp,0,sizeof(dp));
dp[0]=1;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
{
dp[j]+=dp[j-i];
}
printf("%d\n",dp[n]);
}
}

poj1028--动态规划--Ignatius and the Princess III的更多相关文章

  1. hdu acm 1028 数字拆分Ignatius and the Princess III

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  2. hdu 1028 Ignatius and the Princess III(DP)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  3. hdu 1028 Ignatius and the Princess III 简单dp

    题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...

  4. HDOJ 1028 Ignatius and the Princess III (母函数)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  5. HDU1028 Ignatius and the Princess III 【母函数模板题】

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  6. Ignatius and the Princess III

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  7. Ignatius and the Princess III --undo

    Ignatius and the Princess III Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (J ...

  8. Ignatius and the Princess III(母函数)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  9. HDU 1028 Ignatius and the Princess III 整数的划分问题(打表或者记忆化搜索)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1028 Ignatius and the Princess III Time Limit: 2000/1 ...

  10. HDU 1028 整数拆分问题 Ignatius and the Princess III

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

随机推荐

  1. Md2All,把图片轻松上传到云图床,自动生成Markdown

    内容目录 关于Md2AllMd2All的云图床效果直接把图片拖到编辑框截图,直接复制粘贴点图片图标选择图片注册七牛云帐号新建七牛云存储空间设置云图床密钥AK和SKBucketName和BucketDo ...

  2. WEB笔记-CSS 实现多级导航效果

    代码如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  3. 时序分析:DTW算法(基于模板)

    对时序对象进行分析,使用KMP算法可以分析速率不变的模式,参考时序分析:欧式空间轨迹模式识别.使用基于模板匹配的方法,对于速率发生变化的模式,需要用新的对速率要求松散的方法,DTW方法为一种广泛使用的 ...

  4. python write和writelines的区别

    file.write(str)的参数是一个字符串,就是你要写入文件的内容.file.writelines(sequence)的参数是序列,比如列表,它会迭代帮你写入文件. 下面两种方式写入文件的效果是 ...

  5. java操作Excel的poi 格式设置

    格式设置 package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi. ...

  6. PHP并发IO编程实践

    PHP相关扩展 Stream:PHP内核提供的socket封装 Sockets:对底层Socket API的封装 Libevent:对libevent库的封装 Event:基于Libevent更高级的 ...

  7. apache+php连接数据库

    ######## 安装APACHE ##############安装apr/usr/src/apache+php/tar xf apr-1.5.2.tar.gzcd apr-1.5.2./config ...

  8. PHP socket初探 --- 关于IO的一些枯燥理论

    [原文地址:https://blog.ti-node.com/blog...] 要想更好了解socket编程,有一个不可绕过的环节就是IO.在Linux中,一切皆文件.实际上要文件干啥?不就是读写么? ...

  9. mysql查询昨天 一周前 一月前 一年前的数据

    mysql 昨天 一周前 一月前 一年前的数据 这里主要用到了DATE_SUB, 参考如下 代码如下: SELECT * FROM yh_contentwhere inputtime>DATE_ ...

  10. MDK(KEIL5)如何生成.bin文件 【转】

    最近要做个bin文件,网上找了好多都说的不够清楚,后来找到一篇实测可用,说明清楚的,转过来以便学习用. 参考传送门:https://blog.csdn.net/nx505j/article/detai ...