Description

People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, are available in Silverland.

There are four combinations of coins to pay ten credits: 
ten 1-credit coins,
one 4-credit coin and six 1-credit coins,
two 4-credit coins and two 1-credit coins, and
one 9-credit coin and one 1-credit coin. 
Your mission is to count the number of ways to pay a given amount using coins of Silverland.

Input
The input consists of lines each containing an integer meaning an amount to be paid, followed by a line containing a zero. You may assume that all the amounts are positive and less than 300.
Output
For each of the given amount, one line containing a single integer representing the number of combinations of coins should be output. No other characters should appear in the output. 
Sample Input
2
10
30
0
Sample Output
1 4 27

一个很标准的母函数题目,唯一需要改变的就是把+i写成+i*i 因为题意是平方倍的增加

#include<stdio.h>
#include<iostream>
using namespace std;
int n;
int a[],b[];
int main()
{
while(cin>>n)
{ if(n==) break;
for(int i=;i<=n;i++)
{
a[i]=;
b[i]=;
}
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
for(int k=;k+j<=n;k+=i*i)
{
b[k+j]+=a[j];
}
}
for(int z=;z<=n;z++)
{
a[z] = b[z];
b[z] = ;
}
}
cout<<a[n]<<endl;
}
return ;
}

HDU1398 Square Coins的更多相关文章

  1. HDU1398 Square Coins(生成函数)

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  2. HDU-1398 Square Coins(生成函数)

    题意 与$hdu1028$类似,只不过可用的数字都是平方数. 思路 类似的思路,注意下细节. 代码 #include <bits/stdc++.h> #define DBG(x) cerr ...

  3. hdu1398 Square Coins(母函数)

    题目类似于整数拆分,很明显用母函数来做. 母函数的写法基本固定,根据具体每项乘式的不同做出一些修改就行了.它的思路是从第一个括号开始,一个括号一个括号的乘开,用c1数组保存之前已经乘开的系数,即c1[ ...

  4. Square Coins[HDU1398]

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

  5. HDU1398:Square Coins(DP水题)

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

  6. hdu 1398 Square Coins (母函数)

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

  7. hdu 1398 Square Coins(简单dp)

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

  8. HDOJ 1398 Square Coins 母函数

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

  9. Square Coins(母函数)

    Square Coins 点我 Problem Description People in Silverland use square coins. Not only they have square ...

随机推荐

  1. windows系统中启动应用需要的端口被别的程序占用

    开始--运行--cmd 进入命令提示符 输入netstat -ano 即可看到所有连接的PID 之后在任务管理器中找到这个PID所对应的程序如果任务管理器中没有PID这一项,可以在任务管理器中选&qu ...

  2. WEB-INF与Webroot

    WEB-INF:放在WEB-INF下的资源是浏览器访问不到的,但后台程序能跳转到的,但重定向不行

  3. Replace Pioneer注册方法

    Replace Pioneer注册方法 Replace Pioneer过期后,会弹出一个注册(Registration)窗口,其中有一个试用选项(Trial License),点击Trial Lice ...

  4. 关于Bundle对象的思考

    在开发过程中,我们经常使用bundle对象来携带二进制数据,通过INTENT传递出去,那么BUNDLE对象到底是什么?其结构如何? 简要来说,bundle对象类似于一个map,内部是通过<key ...

  5. 关于FILL_PARENTE和match_parent布局属性

    在观看早期的代码的时候,经常会看到FILL_PARENT属性,但是新的代码中却有了MATCH_PARENT 那么,两者有何区别呢? 答案是,没有,只是换了个名字而已,均为-1

  6. ann

    转自 http://blog.csdn.net/yiluoyan/article/details/45308785 这篇文章接着之前的车牌识别,从输入的车图片中分割识别出车牌之后,将进行下一步:车牌号 ...

  7. 数字图像处理实验(5):Proj03-01 ~ Proj03-06 标签: 图像处理matlab 2017-04-30 10:39 184人阅读

    PROJECT 03-01 : Image Enhancement Using Intensity Transformations 实验要求: Objective To manipulate a te ...

  8. ARC100C Linear Approximation

    传送门 分析 这道题真的好水呀QwQ,想必大家都知道对于式子|x-2|+|x-3|x取什么值可以使式子结果最小,这道题也是这个原理,只需要将要额外减的1.2.3……提前减掉就行了. 代码 #inclu ...

  9. 前端基础 之 BOM和DOM

    浏览目录 背景 BOM window对象 window的子对象 DOM HTML DOM树 查找标签 节点操作 事件 一.背景 到目前为止,我们已经学过了JavaScript的一些简单的语法.但是这些 ...

  10. netty中的位操作

    看了PoolChunk源码,好多位操作,对这些位操作理解不到位,看起来很是吃力,不知道为什么要这么做,可能是性能更好 1:大小为2 的冥的数加1 怎么操作 size^1; 2: <=比较   m ...