Ignatius and the Princess III
Ignatius and the Princess III
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10312 Accepted Submission(s): 7318
"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!"
10
20
42
627
#include<stdio.h>
int a[],b[]; // a[i]表示x^i的系数,为临时值,b[i]表示x^i的系数,为最终值;
int main()
{
int i,j,k,n;
for(i =;i <=;i ++)
{
a[i] =;
b[i] =;
}
for(i =;i <=;i ++)
{
for(j =;j <=;j ++)
{
for(k =;k+j <=; k += i)
a[k+j] += b[j]; //因为x^(k+j)是从x^j得来的,故它的系数应该在原有系数的数值的基础上加上x^j
的系数(这是关键的重点!!!这就是为什么我们要用两个数组的目的)
}
for(j =;j <=;j ++)
{
b[j] = a[j];
a[j] =;
}
}
while(~scanf("%d",&n))
printf("%d\n",b[n]);
return 0;
}
Ignatius and the Princess III的更多相关文章
- 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 ...
- 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 ...
- hdu 1028 Ignatius and the Princess III 简单dp
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- HDOJ 1028 Ignatius and the Princess III (母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU1028 Ignatius and the Princess III 【母函数模板题】
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- Ignatius and the Princess III --undo
Ignatius and the Princess III Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (J ...
- Ignatius and the Princess III(母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- 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 ...
- HDU 1028 整数拆分问题 Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- Swift 一些环境配置
#if DEBUG 使用 如下图配置即可使用
- Multiple methods named 'status' found with mismatched result, parameter type or attributes
出现这个这个错误, 有可能是由于你直接通过一个数组的索引获取一个对象(或模型)然后直接调用这个对象(或模型)的某个方法 例如: NSString *status = [self.models[inde ...
- NODE JS拼命吹,我就不喜欢. 别问为什么,直觉.
NODE JS拼命吹,我就不喜欢. 别问为什么,直觉. 来看看node js 在paypal的捣鼓文章吧.https://www.paypal-engineering.com/2013/11/22/n ...
- 配置php连接apache
配置php连接apache 1.安装php所需要的库 yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel li ...
- mysql SELECT INTO OUTFILE ,can't create file (转)
原文 http://blog.sina.com.cn/s/blog_6a5e34ad0100zfbi.html (转) 命令行模式进入mysql #mysql -uroot -p12345 #sel ...
- initrd.gz的解压和制作
解压: gzip -d initrd.gz cpio -idmv < initrd 压缩: find . | cpio -o -c > initrd.img gzip initrd.img ...
- wamp集成环境php多版本搭建(php5.5,php5.6,php7.0.6)
首先需要搭建的版本可以在php官方(http://windows.php.net/download)下载对应的版本,X86对应的是32位操作系统,X64对应的是64位操作系统. 1:下载 ...
- [CUDA] ubuntu14.04+cuda7.5下安装cudnn7.0
cuda:7.5 cudnn:cudnn-7.0-linux-x64-v4.0-prod.tgz cudnn样例:cuDNN v4 Code Samples 1. 解压 tar -zxvf cudnn ...
- winform 两个TreeView间拖拽节点
/// <summary> /// 正在拖拽的节点 /// </summary> private TreeNode DragNode = null; /// <summa ...
- cli下的php(并传递参数)
传递参数有两种方式: 第一种使用文件操作,STDOUT作为标准输出,STDIN作为标准输入 使用fwrite($file,$string)作输出,使用fgets($file)作输入.这种应该算是继承自 ...