有1,4,9,16,25.....2^17这么多面值的硬币,问任意给定一个不大于300的正整数面额,用这些硬币来组成此面额总共有多少种组合种数

比如10
全1
4 + 6个 1
4+4+1+1
9+1

求(1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^10)(1+x^4+x^8)(1+x^9)中
x^10的系数即可

只是把模板的 i<=n改成了i*i<=n,
在k遍历指数时把k=k+i变成了k=k+i*i

Sample Input
2
10
30
0

Sample Output
1
4
27

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <list>
# define LL long long
using namespace std ; int c1[], c2[] ;
int main()
{
//freopen("in.txt","r",stdin) ;
int n;
int i, j, k;
while(cin >> n)
{
if (n == )
break ;
for(i=; i<=n; ++i)
{
c1[i] = ;
c2[i] = ;
}
for(i=; i*i<=n; ++i)
{ for(j=; j<=n; ++j)
for(k=; k+j<=n; k += i*i)
{
c2[j+k] += c1[j];
}
for(j=; j<=n; ++j)
{
c1[j] = c2[j];
c2[j] = ;
}
}
cout << c1[n] << endl;
}
return ;
}

hdu 1398 整数划分变形 (母函数)的更多相关文章

  1. hdu 1028 & hdu 1398 —— 整数划分(生成函数)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1028 整数划分,每个数可以用无限次: 所以构造 f(x) = (1+x+x2+x3+...)(1+x2+x ...

  2. hdu 1028 整数划分 (母函数)

    假如输入44 = 4;4 = 3 + 1;4 = 2 + 2;4 = 2 + 1 + 1;4 = 1 + 1 + 1 + 1;一共5种 假如输入3 用母函数的方法就是写成(1+X+X2+X3)(1+X ...

  3. Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数

    Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...

  4. 大概是:整数划分||DP||母函数||递推

    整数划分问题 整数划分是一个经典的问题. Input 每组输入是两个整数n和k.(1 <= n <= 50, 1 <= k <= n) Output 对于每组输入,请输出六行. ...

  5. HDU 1398 Square Coins 整数拆分变形 母函数

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  6. HDU acm1028 整数划分 递归问题(递推)

    我们用递归+记忆化的方法来解决普通整数划分问题:定义 f(n,m)为将整数n划分为一系列整数之和,其中加数 最大不超过m. 得到下面的递推关系式: 当n==1 || m==1 只有一种划分,即 1 或 ...

  7. 题解报告:hdu 1398 Square Coins(母函数或dp)

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  8. hdu 5230 整数划分 dp

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5230 题意:给定n,c,l,r.求有多少种方法从1~n-1选取任意k数每个数的权重为其下标,使得这些数字之 ...

  9. HDU 1398 Square Coins(母函数或dp)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

随机推荐

  1. Qt ------ 截图、获取鼠标指定的RGB值

    获取RGB值思路:截图,获取图片的(0,0)的RGB值 int x = QCursor::pos().x(); int y = QCursor::pos().y(); // QPixmap pixma ...

  2. docker:轻量级图形页面管理之Portainer

    docker:轻量级图形页面管理之Portainer 原创甘兵2018-03-05 14:26:56评论(8)2586人阅读   1.介绍 docker 图形化管理提供了很多工具,有Portainer ...

  3. 逻辑回归--美国挑战者号飞船事故_同盾分数与多头借贷Python建模实战

    python信用评分卡(附代码,博主录制) https://study.163.com/course/introduction.htm?courseId=1005214003&utm_camp ...

  4. 关于connect by 误区讲解,纯属个人心得和经验,有图有文字

    本博客是自己在学习和工作途中的积累与总结,仅供自己参考,也欢迎大家转载,转载时请注明出处. http://www.cnblogs.com/king-xg/p/6927541.html 如果觉得对您有帮 ...

  5. 转:iOS-CoreLocation:无论你在哪里,我都要找到你!

    1.定位 使用步骤: 创建CLLocationManager示例,并且需要强引用它 设置CLLocationManager的代理,监听并获取所更新的位置 启动位置更新 1 2 3 _manager = ...

  6. Django 2.0.1 官方文档翻译:编写你的第一个 Django app,第六部分(Page 11)

    编写你的第一个 Django app,第六部分(Page 11)转载请注明链接地址 本教程上接前面第五部分的教程.我们构建了一个经过测试的 web-poll应用,现在我们会添加一个样式表和一张图片. ...

  7. bootstrap使用记录

    http://v3.bootcss.com/components/#panels http://v2.bootcss.com/components.html

  8. [转载]bootstrap 2.3版与3.0版的使用区别

    http://www.weste.net/2013/8-20/93261.html bootstrap已经推出了3.0的新版,看起来2.3.x版本也不会再更新了.那么bootstrap 2.3版与3. ...

  9. ARC官方文档翻译! - iPhone App开发外包专区 - 威锋论坛 - 威锋网

    CHENYILONG Blog ARC官方文档翻译! - iPhone App开发外包专区 - 威锋论坛 - 威锋网  http://bbs.weiphone.com/read-htm-tid-344 ...

  10. Spiral Matrix I & II

    Spiral Matrix I Given an integer n, generate a square matrix filled with elements from 1 to n^2 in s ...