HDU 1398 Square Coins
题目大意:有面值分别为。1,4,9,.......17^2的硬币无数多个。问你组成面值为n的钱的方法数。
最简单的母函数模板题:
#include <cstdio>
#include <cstring>
using namespace std;
int c1[305],c2[305],n;
int main(){
while(scanf("%d",&n),n){
for(int i=0;i<=n;i++)c1[i]=1,c2[i]=0;
for(int i=2;i<18;i++){
for(int j=0;j<=n;j++){
for(int k=0;k+j<=n;k+=i*i)c2[j+k]+=c1[j];
}
memcpy(c1,c2,sizeof c2); memset(c2,0,sizeof c2);
}
printf("%d\n",c1[n]);
}
}
HDU 1398 Square Coins的更多相关文章
- hdu 1398 Square Coins 分钱币问题
Square Coins Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- 题解报告:hdu 1398 Square Coins(母函数或dp)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- hdu 1398 Square Coins(生成函数,完全背包)
pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...
- HDU 1398 Square Coins 整数拆分变形 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- 杭电ACM hdu 1398 Square Coins
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- HDU 1398 Square Coins(母函数或dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- HDU 1398 Square Coins(DP)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- android入门——UI(4)
GridView控件实现菜单 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...
- spring mvc框架 遇到的问题
web.xml配置文件代码: <?xml version="1.0" encoding="UTF-8"?> <web-app version= ...
- UITableViewCell的4种样式
转自http://blog.csdn.net/crazyzhang1990/article/details/12503163 1.UITableViewCellStyleDefault: Defaul ...
- ubuntu, Debian, CentOS
ubuntu源自debian,内核很多文档都还是debian的字样,稳定性逐渐增强,基本满足日常开发. debian的核心稳定,性能强劲. centos的内核版本低,安全性高. 选择Debian是因为 ...
- CSS截取字符串
/*溢出的字...处理*/ .updatecsssubstring { text-overflow: ellipsis; -o-text-overflow: ellipsis; white-space ...
- 查看SQLServer数据库信息的SQL语句
--查看数据库中的表信息, --包括(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_MSForEachTable @precommand=N'create table # ...
- 移动前端制作篇之javascript篇
javascript(简称js)语言在移动前端应用很广.可以说必不可少,许多效果都是和js相关的.包括现在移动端的一些框架.jqmobi.jqtouch.sencha touch.jquerymobi ...
- jquery 工作笔记,不断整理中..
$('input:radio[name="ruleType"]:checked').val() //获得radio选中的值 $("input[name='Q_lastU ...
- 仅返回类型不同的函数,在C++中如何实现重载?
C++支持函数重载,所谓重载就是在同一命名空间内,函数名相同,参数不同(参数个数或参数类型不同)的函数可以共存.但是若参数和函数名相同的话,编译器会报错不能重载.但是现实中,有时候仅仅需要返回类型不同 ...
- 将 SQL Server 实例设置为自动启动(SQL Server 配置管理器)
本主题说明如何使用 SQL Server 配置管理器在 SQL Server 2012 中将 SQL Server 实例设置为自动启动. 在安装过程中,SQL Server 通常配置为自动启动. 如果 ...