Ignatius and the Princess III

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

Total Submission(s): 16242    Accepted Submission(s): 11445

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
 
Author
Ignatius.L

#include<stdio.h>
#include<string.h>
#define max 100+30
int main()
{
int c1[max],c2[max];
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<=n;i++)
{
c1[i]=1;
c2[i]=0;
}
for(int i=2;i<=n;i++)//从第二个多项式开始乘
{
for(int j=0;j<=n;j++)//在第一个多项式中的每一项与后边的相乘
for(int k=0;k+j<=n;k+=i)//在第i个多项式中的每一项与前边的相乘
c2[k+j]+=c1[j];
for(int j=0;j<=n;j++)
{
c1[j]=c2[j];//更新现在第一个多项式中的每一项的系数
c2[j]=0;
}
}
printf("%d\n",c1[n]);
}
return 0;
}

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

  1. HDOJ 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 母函数

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

  3. hdoj 1028 Ignatius and the Princess III(区间dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 思路分析:该问题要求求出某个整数能够被划分为多少个整数之和(如 4 = 2 + 2, 4 = 2 ...

  4. HDOJ 1028 Ignatius and the Princess III(递推)

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

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

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

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

  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. hdu 1028 Sample Ignatius and the Princess III (母函数)

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

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

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

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

随机推荐

  1. Android 低功耗蓝牙的多设备连接与数据接收,简单实现

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  2. web拼图错误分析

    老师要求用web制作一个拼图游戏. 发现的问题:点击随机生成拼图的按钮后,打乱的图片会出现无法还原的情况. 发现过程:每次生成一个拼图后会测试它怎么拼回去,结果发现有时候拼不回去. 数学原理:如果两个 ...

  3. Android--XML页面的编写

           五个页面  代码如下:    图片资源链接: https://pan.baidu.com/s/1jIoTDGE //  第一个 <RelativeLayout xmlns:andr ...

  4. 时间&物质&效率

    由于我的家庭是地道的农民家庭,在上学的时候,父母很辛苦的供我读初中,高中,大学. 现在我想说的是,用时间来换取效率是我求学时最大的遗憾. 举一个例子吧:每次回家坐火车,火车很费时间,假如我不缺钱,完全 ...

  5. Service、chkconfig命令

    转自:http://my.oschina.net/phptiger86/blog/137656

  6. go开发和运行环境的配置

    1.运行环境的下载.安装.配置: 下载:http://www.golangtc.com/download  官网下载经常被墙屏蔽,所以就从golang中国下载; 安装及其配置:http://jingy ...

  7. dotnetnuke7.3.3 下弹出对话框(dnnConfirm())的使用

    今天用dnn做一个列表里边有一个删除操作,就想做个对话框确定是否删除? 正常理解马上想到js的confirm("")函数,但是发现Dnn把这个函数给重写啦,弹出的对话框竟然是英文的 ...

  8. Struts2学习笔记 - Part.02

    ================Struts2的国际化================程序国际化: 程序可以根据极其所在的国家.语言环境,自动显示当前国家.语言的内容国际化的本质是:查找.替换国际化的 ...

  9. 运行于Windows内建账户下的服务访问映射网络驱动器的方法

    Windows服务如果是运行在本地系统帐户下或本地服务帐户下,它只能访问这个账户自己创建的映射驱动器,UNC路径访问则不受次限制. LocalService Account (NT AUTHORITY ...

  10. PythonOpenCV--Rtrees随机森林

    360确实很个性,哈哈,你个貔貅,只吃不吐! Rtrees介绍!参考链接:http://docs.opencv.org/modules/ml/doc/random_trees.html 原文链接:Py ...