Ignatius and the Princess III

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

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

::简单的DP题

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[125]={1,0}; int main()
{
ios::sync_with_stdio(0);
for(int i=1; i<=120 ; i++ )//当只有不大于i的数
for(int j =i ; j<=120 ; j++ )
dp[j] += dp[j-i]; int n;
while(cin>>n)
cout<<dp[n]<<endl;
return 0;
}

hdu 1028 Ignatius and the Princess III(DP)的更多相关文章

  1. HDU 1028 Ignatius and the Princess III dp整数划分

    http://acm.hdu.edu.cn/showproblem.php?pid=1028 dp[i][j]表示数值为i,然后最小拆分的那个数是j的时候的总和. 1 = 1 2 = 1 + 1 . ...

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

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

  3. 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 ...

  4. 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 ...

  5. hdu 1028 Ignatius and the Princess III (n的划分)

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

  6. hdu 1028 Ignatius and the Princess III 母函数

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

  7. HDU 1028 Ignatius and the Princess III (递归,dp)

    以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802  Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意 ...

  8. HDU 1028 Ignatius and the Princess III (动态规划)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

  9. HDU 1028 Ignatius and the Princess III (生成函数/母函数)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

随机推荐

  1. 面向对象的Javascript(5):继承

    在小项目中对于JavaScript使用,只要写几个function就行了.但在大型项目中,尤其是在开发追求 良好的用户体验的网站中,如SNS,就会 用到大量的JavaScrpt,有时JavaScrip ...

  2. Javascript语法去控制Web控件的Enabled属性

    Web控件当使用Enabled属性时,它生成html之后会变成了disabled了.我们为了能够在javascript去控制控件的禁用与启用,得从这个disabled入手.如:

  3. 克隆复制可使用原型( Prototype)设计模式

    今天有学习设计模式的原型(Prototype)<设计模式--原型(Prototype)模式>http://www.cnblogs.com/insus/p/4152773.html .为了加 ...

  4. Winform开发框架之权限管理系统改进的经验总结(1)-TreeListLookupEdit控件的使用

    最近一直在做一些技术性的研究和框架改进工作,博客也落下好几天没有更新了,也该是时候静下心来,总结这段时间的一些技术改进的经验了.和上一阶段的CRM系统开发和技术研究一样,我都喜欢在一个项目或者模块完成 ...

  5. 【原创】Silverlight客户端发起WebRequest请求分析

    Silverlight网站部署后,客户端浏览器访问的时候会 下载 网站的xap文件包等信息,把程序代码放到本地执行,因为本地机器上安装了silverlight运行库. 所以如果silverlight前 ...

  6. MAC OS X 系统怎么样?

    朝鲜的 IT 应用状况并不为外界所熟知,过去媒体纷纷报道,朝鲜已故领导人金正日酷爱苹果电子产品,而最近一份调查报告显示,在朝鲜个人电脑操作系统市场,苹果 MAC OS X 系统位居第一名,遥遥领先微软 ...

  7. vmware screen

    1. Question Description: the screen of the vmware looks small . 2. Solution: 2.1 look the size of sc ...

  8. python基础之基本算法和装饰器

    1.冒泡排序 关于冒泡排序实现大小比较,大索引会向后移动,这次循环将最大数值直接移动至最后. li = [,,,,] ): ]: temp = li[i] li[i] = li[i + ] li[i ...

  9. Math对象常用方法汇总

    前几天翻阅<JavaScript权威指南>,看到了Math对象,于是汇总了一下. Math对象不同于其他的对象,它可以说是一个公共数学类,里面有很多数学方法,用于各种数学运算,但是Math ...

  10. 微信html5开发选哪一个

        html5选哪个开发框架       ①. Justep起步 X5框架 : 专门用来开发web App的大型开发工具集,x5 v3.0有765.58M,不选. ②.Jquery Mobile ...