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 ...
随机推荐
- UIImageView的图片拉伸
iOS 8:UIView Stretching设置 使用小图片当变长输入框或类似QQ聊天文字背景效果时,需要拉伸图片.UIImage提供了三个可完成此任务的方法: resizableImageWith ...
- O-C相关06:self和super关键字介绍——self关键字
self关键字介绍 1.self和super OC 版权声明:本文为博主原创文章,未经博主允许不得转载. posted @ 2015-08-04 12:46 王刚韧(wanghy_iOS) 阅读(.. ...
- requirejs下载与配置
写在开始: requirejs有中文版api文档,可以访问http://www.requirejs.cn/home.html 下载requirejs 访问http://www.requirejs.cn ...
- VS中使用sqlite静态连接
说明 最近写的文章有些多,懒得打字了,就直接上文章.这里说明一下,我说的是VS,不是指定的哪一个VS版本.先下载官方的源文件:sqlite-amalgamation-3071502.zip 下载下来的 ...
- Nginx(一)初始环境的安装(php5.3+mysql5.1+fastcgi…)
关参考资源http://www.lnmp.org/index.html \\LNMP一键安装包http://www.howtocn.org/nginx \\Nginx模块参考手册中文版http://b ...
- 给定任意一个字符串,使用 for in 语句来统计字符出现的个数
//找出字符串中的数字 var str = 'haj123sdk54hask33dkhalsd879'; /*function findNum(str){ var arr = []; var tmp ...
- 初用jquery
---恢复内容开始--- 这两天在顶顶大人的指导下,利用jquery框架做了一个动态切换的小页面.最终效果图: 这么萌萌哒的图片让我觉得一直在测试也没那么累.实现功能如下: 1.打开页面时,自动切换, ...
- 移动web问题小结
Meta标签: <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalab ...
- angularjs制作的iframe后台管理页切换页面
<code> <!DOCTYPE html><html lang="zh" ng-app><head> <meta chars ...
- node 通过mongoose实现 mongodb的增删改
node 通过mongoose实现 mongodb的增删改 新建文件test.js 内容如下: var mongoose = require('mongoose') , Schema = mo ...