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. 【Oracle】DG三种保护模式及切换方式

    一.三种保护方式 Required Redo Transport Attributes for Data Protection Modes Maximum Availability Maximum P ...

  2. SmartUpload实现文件上传

    (一)SmartUpload组件简介 SmartUpload组件 专门用于实现文件上传及下载的免费组件   (二)SmartUpload组件特点 使用简单:编写少量代码,完成上传下载功能 能够控制上传 ...

  3. 利用Xpath和jQuery进行元素定位示例

    利用Selenium在做前端UI自动化的时候,在元素定位方面主要使用了XPATH和jQuery两种方法.XPATH作为主要定位手段,jQuery作为补充定位手段.因为在通过XPATH进行定位的时候,S ...

  4. 【剑指Offer】8、跳台阶

      题目描述:   一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果).   解题思路:   首先考虑最简单的情况,如果只有1级台阶, ...

  5. UNIX C 文件权限 Part2_day01

    1.文件访问测试 测试调用进程对指定文件是否拥有足够的访问权限 #include <unistd.h> int access(const char* pathname,int mode); ...

  6. 算法工程师首先是工程师系列01 - 服务器篇 - 物理服务器安装centos7

    尤其在互联网公司中,如果不是分工特别明确的独立业务组,通常需要自己处理很多东西,例如一个算法工程师,虽然不要求你装机,但是和负责部署服务的同事对接口,总不能连json是啥都不知道(工作中遇到过一个ET ...

  7. 32.es读请示内部分发原理

    当客户端发送一次读请求时,大致会经过以下几个步骤 1.客户端发送一个请求过去,es的一个node接收到这个请求(随机的node),这个node就被es内部分配成coordinating node(协调 ...

  8. 2.IntelliJ IDEA 下载破解(2017)

    1.首先,我找到了 IntelliJ IDEA的官网:www.jetbrains.com 然后找到下载的地方,选择自己电脑所匹配的下载安装包,这里我们选择收费版的下载,因为免费版的功能并没有收费版的强 ...

  9. AnimationEvent事件问题

    AnimationEvent事件问题 本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/deta ...

  10. RMAN主要命令 show,list,crosscheck,delete详解

    Oracle RMAN 的 show,list,crosscheck,delete命令整理  Oracle RMAN 的 show,list,crosscheck,delete命令整理 1.SHOW命 ...