Square Coins

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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 dp[i]=dp[i-mon[i]]+dp[i]

hdu 1398 Square Coins 分钱币问题的更多相关文章

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

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

  2. hdu 1398 Square Coins (母函数)

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

  3. hdu 1398 Square Coins(简单dp)

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

  4. hdu 1398 Square Coins(生成函数,完全背包)

    pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...

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

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

  6. 杭电ACM hdu 1398 Square Coins

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

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

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

  8. HDU 1398 Square Coins(DP)

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

  9. HDU 1398 Square Coins

    题目大意:有面值分别为.1,4,9,.......17^2的硬币无数多个.问你组成面值为n的钱的方法数. 最简单的母函数模板题: #include <cstdio> #include &l ...

随机推荐

  1. 洛谷——P1469 找筷子

    P1469 找筷子 题目描述 经过一段时间的紧张筹备,电脑小组的“RP餐厅”终于开业了,这天,经理LXC接到了一个定餐大单,可把大家乐坏了!员工们齐心协力按要求准备好了套餐正准备派送时,突然碰到一个棘 ...

  2. POJ3261 Milk Patterns(二分+后缀数组)

    题目求最长的重复k次可重叠子串. 与POJ1743同理. 二分枚举ans判定是否成立 height分组,如果大于等于ans的组里的个数大于等于k-1,这个ans就可行 #include<cstd ...

  3. 如何隐藏 video 元素的下载按钮

    1. 使用 video 元素的 ControlList API <video controls controlsList="nodownload"></video ...

  4. 获取SQLServer的最完整数据字典的SQL语句

    原文:获取SQLServer的最完整数据字典的SQL语句 原创于2008年06月18日,2009年10月18日迁移至此. 获取SQLServer 的最完整数据字典的SQL 语句   其实网上已经流传了 ...

  5. 提高MSSQL数据库性能(1)对比count(*) 和 替代count(*)

    原文:提高MSSQL数据库性能(1)对比count(*) 和 替代count(*) 文章准备的数据库: Atricles 表   数据量60690000条数据 ArticleID 主键自增列+自动建立 ...

  6. 在vs2012中配置使用iisexpress

    在vs2012中配置使用iisexpress   vs2012支持基于iisexpress的web站点调试,这样可以尽可能与生产环境具备一样的环境. 但是,如果在vs2012中直接配置iis目录,通常 ...

  7. python测试与调试提示

    测试与调试提示 2.1 在交互模式输入一个python语句就会执行一个.在调试程序时,这种模式尤其有用. 2.2 在一个文件调用python解释器后,解释器会在文件中的最后一个语句执行之后推出.然而, ...

  8. ElasticSearch 相关性

    1.相关性 ElasticSearch检索结果是按照相关性倒序排列的,相关性是什么,相关性又是如何计算的?每个文档都有相关性评分,用一个正浮点数字段 _score 来表示 . _score 的评分越高 ...

  9. 获取本机IP,用户代理

    1.获取本机IP:http://httpbin.org/ip 2.获取用户代理 https://httpbin.org/user-agent https://httpbin.org/ httpbin( ...

  10. Java 学习之网络编程案例

    网络编程案例 一,概念 1,网络编程不等于网站编程 2,编程只和传输层打交道,即TCP和UDP两个协议 二,案例 1,TCP实现点对点的聊天 Server端:两个输入流:读客户端和控制台,一个输出端: ...