码迷,mamicode.com
首页 >  
搜索关键字:hdu1028    ( 22个结果
几个相似的DP题
HDU1398 题意:把一个整数分拆成1、4、9、16、……、256、289(注意:只到289)这17个完全平方数的和,有几种方法。 解法不用说自然是DP,因为搜索显然超时。 (这样的题我一般不敢开int,怕爆……) HDU1028 自然数无序拆分 恩,经典的DP题 二维的方法……但是我以前用一维的 ...
分类:其他好文   时间:2016-11-12 20:06:22    阅读次数:251
hdu1028 划分数
题意是将一个整数N划分成不超过N个整数的和, 我们定义d[i][j]为j划分成不超过i个整数的和的方案数, 那么d[i][j] = d[i][j-i](全大于0) + d[i-1][j](不全大于0)。 答案就是d[N][N], 代码如下: #include <iostream> #include
分类:其他好文   时间:2016-02-25 01:41:22    阅读次数:128
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 are later." feng5166 says. "The second problem is, give...
分类:其他好文   时间:2015-08-19 19:36:59    阅读次数:93
[hdu1028]整数拆分,生成函数
题意:给一个正整数n,求n的拆分方法数(不考虑顺序)思路:不妨考虑用1~n来构成n。用多项式表示单个数所有能构成的数,用多项式表示,就相当于卷积运算了。12345678910111213141516171819202122232425262728293031323334353637383940414...
分类:其他好文   时间:2015-08-04 12:40:23    阅读次数:122
HDU1028 Ignatius and the Princess III【母函数】【完全背包】
题目大意: 给定正整数N,定义N = a[1] + a[2] + a[3] + … + a[m],a[i] > 0,1 <= m <= N。 对于给定的正整数N,问:能够找出多少种这样的等式? 思路: 对于N = 4, 4 = 4; 4 = 3 + 1; 4 = 2 + 2; 4 = 2 + 1 + 1; 4 = 1 + 1 + 1 + 1。 共有5种。N=4时,结果就是5。其实就是整数分解问题,可写出母函数 g(x) = (1+x+x^2+x^3+…)*(1+x^2+x^4+…)*(1+x^3+…)*(...
分类:其他好文   时间:2015-05-14 23:52:32    阅读次数:137
hdu1028 Ignatius and the Princess III
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1028递归能跑。。。但是我交了直接超时了,然后我就把数据跑出来了再交的,等的时间有点长(怪不得超时)。过的有点猥琐,看别人代码用母函数过的。 1 #include 2 #include 3 #includ...
分类:其他好文   时间:2015-04-18 21:51:56    阅读次数:116
hdu1028(整数划分问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028整数划分问题整数划分 --- 一个老生长谈的问题:描述整数划分是一个经典的问题。请写一个程序,完成以下要求。输入每组输入是两个整数n和k。(1 j时,可以根据划分中是否含有j分为两种情况。若划分中含...
分类:其他好文   时间:2014-11-24 13:32:32    阅读次数:290
ACM学习历程—HDU1028 Ignatius and the Princess(组合数学)
Ignatius and the Princess Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "T...
分类:其他好文   时间:2014-11-16 20:04:47    阅读次数:204
hdu1028:整数拆分
求整数的拆分数。。一种解法是母函数#include #include #include#include#include#includeusing namespace std;#define MAXN 10000int dp[2][130];int main(){ int n; while...
分类:其他好文   时间:2014-11-07 20:44:38    阅读次数:173
hdu1028(母函数+DP)
题目信息:求分解整数n的个数q(n);可以母函数或者DP http://acm.hdu.edu.cn/showproblem.php?pid=1028 AC代码: /****************************** 题目大意:求分解整数n的个数q(n) 例: 5 = 5; 5 = 4 + 1; 5 = 3 + 1 + 1; 5 = 3 + 2; 5 ...
分类:其他好文   时间:2014-10-26 19:47:16    阅读次数:139
22条   上一页 1 2 3 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!