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 ...
随机推荐
- C++ Union妙用(将列表初始化用于数组元素)
Union是个不被注意的关键字,意为联合体,这是个诡异的名字.若不是为了继承C语言,它也不会出现在C++中(虽说,union在C++中得到了扩充,完成了接近类的功能).它的作用主要是节省内存空间,在嵌 ...
- java三大特性性:封装、继承和多态
一.封装 封装是指隐藏对象的属性及实现细节,对外仅提供接口可见.封装实现了信息隐藏,利于软件复用.其优点是达到了模块化的标准,从而提高了代码的复用程度.在某种程度上,封装也大大改善了软件开发的可维护性 ...
- File的文件提取的小练习
package com.java.Dmeo1.www; import java.io.File;import java.util.LinkedList;import java.util.TreeSet ...
- IDE开发<LER-Studio>(2)::登录模块
软件中写登录模块是为了防止软件的恶意传播,内测阶段可以忽略登录. 以下为登录模块主要源代码: void CLoginDlg::OnBnClickedBtnLogin() { // TODO: Add ...
- MySQL分库分表备份脚本
MySQL分库备份脚本 #脚本详细内容 [root@db02 scripts]# cat /server/scripts/Store_backup.sh #!/bin/sh MYUSER=root M ...
- sql的连接查询方式
1 SQL join 用于根据两个或多个表中的列之间的关系,从这些表中查询数据. Join 和 Key 有时为了得到完整的结果,我们需要从两个或更多的表中获取结果.我们就需要执行 join. 数据库中 ...
- js获取url的get传值函数
function getvl(name) { var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s| ...
- php快递单号查询源码
贴下记录下php查询快递单号的源码,能查询各种快递的快递单号记录,中通.圆通快递.顺丰快递等都不是问题.只需要在 爱快递(www.aikuaidi.cn)上面申请一个快递key即可,下面把源码分享下, ...
- SQL 多条件查询
网上有不少人提出过类似的问题:“看到有人写了WHERE 1=1这样的SQL,到底是什么意思?”.其实使用这种用法的开发人员一般都是在使用动态组装的SQL.让我们想像如下的场景:用户要求提供一个灵活的查 ...
- 查看用户列表在Linux
Linux下查看用户列表 原文地址:http://xiaod.in/read.php?77 俺的centos vps上面不知道添加了多少个账户,今天想清理一下,但是以前还未查看过linux用户列表 ...