Square Coins
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3600Accepted Submission(s): 2458
Problem 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
Sample Output
Source
做法:仍然是最基本的母函数,只需要把完全平方数事先预处理存起来即可
我的代码:
分享到:
相关推荐
收集的部分HDOJ杭电ACM题的代码 大牛勿下 全是基础供初级acmer使用
(HDUACM2010版_08)母函数(HDUACM2010版_08)母函数(HDUACM2010版_08)母函数(HDUACM2010版_08)母函数(HDUACM2010版_08)母函数(HDUACM2010版_08)母函数
自己积累的部分杭电oj的(hdu)解题代码。。大家有空来看看。 基本上是自己写的哈。有错误之处请指教、
ACM培训好资料!能帮助你快速提高ACM AC题目的能力,值得一下
杭电oj4405,一道简单的概率dp题目
90%的杭电母函数解题报告,有题目加解题思路,和ac掉的代码
杭电acm解题报告 详细解析2000-2099 适合acm初学者
ACM ICPC HDOJ1000
hdu 1695 GCD(欧拉函数+容斥原理).docx
acm 技术大牛 课件 HDU ...(lecture_06)母函数 (lecture_7)特殊的数 (lecture_8)组合博弈入门 (lecture_09贪心算法 (lecture_11)搜索入门 (lecture_12)二分匹配及其应用 (lecture_13)动态规划(2) 并查集
杭州电子科技大学hdoj1002,大整数相加问题
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
hdoj的一些题目分类,由hdu大牛搜集,希望对做ac的同志们有帮助
HDU1059的代码
杭电ACMhdu1163
HDU ACM 2005第几天 C++ http://acm.hdu.edu.cn/listproblem.php?vol=11 2005题 第几天?
hdu1001解题报告
ACM ICPC HDOJ 1005
hdu 1574 passed sorce