Ignatius and the Princess III

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

Total Submission(s): 13553    Accepted Submission(s): 9590

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>
int a[130],s[130];
int main()
{
int n,i,j,k;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n;i++)
{
a[i]=0;
s[i]=1;
}
for(i=2;i<=n;i++)
{
for(j=0;j<=n;j++)
{
for(k=0;k+j<=n;k+=i)
a[k+j]+=s[j];
}
for(j=0;j<=n;j++)
{
s[j]=a[j];
a[j]=0;
}
}
printf("%d\n",s[n]);
}
return 0;
}

Ignatius and the Princess III(杭电1028)(母函数)的更多相关文章

  1. HDU 1028 Ignatius and the Princess III:dp or 母函数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = ...

  2. ACM学习历程—HDU1028 Ignatius and the Princess III(递推 || 母函数)

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

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

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

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

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

  6. Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数

    Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...

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

  8. HDOJ 1028 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

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

随机推荐

  1. How-to-quick-getting-started-for-Frontend

    一转眼已一年多不专注前端方面的开发工作,这一年前端方面的技术又是新天地,偶然接到内部团队邀请我给他们做一个前端的讲座,希望能帮助他们快速.且深刻了解前端这个行业以及行业内的知识,这可真有点让我为难,由 ...

  2. 循环语句第1种 LOOP ... END LOOP;

     7)循环语句  --------第1种----------   LOOP ... END LOOP;    declare    n number(3) := 1;  begin    LOOP   ...

  3. 洛谷 2409 dp 月赛题目

    洛谷 2409 dp 洛谷十月月赛T1,一道有些interesting的dp题目,当时做的时候想的比较复杂,根本没有往dp的方向去想.. 非官方题解: 1.据说可以使用优先队列来处理,参见Uva119 ...

  4. 在CentOS6.5下配置安装LVS

    先上一个图,在内网测试机上安装了一个虚拟机,已经安装好了CentOS 乖乖连wget都没有安装,先安装wget吧 sudo yum install wget

  5. Spring中基于Java的配置@Configuration和@Bean用法 (转)

    spring中为了减少xml中配置,可以生命一个配置类(例如SpringConfig)来对bean进行配置. 一.首先,需要xml中进行少量的配置来启动Java配置: <?xml version ...

  6. System.arraycopy用法

    System.arraycopy用法 注意长度的设置: public class ArrCopy { public static void main(String[] args) { int [] s ...

  7. Maven导入ojdbc14.jar和ojdbc6.jar

    Maven导入ojdbc14.jar和ojdbc6.jar 学习了:http://blog.csdn.net/johon_medison/article/details/51689690 在 ‘运行’ ...

  8. 创建一个web user control

    1.创建文件 添加,然后选择web user control 2.添加控件 在工具栏搜索button,然后拖动三个button上去 <%@ Control Language="C#&q ...

  9. C#各个版本中的新增特性详解【转】

    序言 自从2000年初期发布以来,c#编程语言不断的得到改进,使我们能够更加清晰的编写代码,也更加容易维护我们的代码,增强的功能已经从1.0搞到啦7.0甚至7.1,每一次改过都伴随着.NET Fram ...

  10. Java多线程编程模式实战指南(一):Active Object模式--转载

    本文由黄文海首次发布在infoq中文站上:http://www.infoq.com/cn/articles/Java-multithreaded-programming-mode-active-obj ...