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. H. Fake News (medium)

    H. Fake News (medium) 题意 以前是给出 S T 串,问在 S 中有多少个子串为 T 的个数,子串可以不连续,保持位置相对一致. 现在给出 n ,要你构造 S T 串. 分析 这种 ...

  2. python查询mangodb

    from bson.objectid import ObjectId import pymongo   #查询代码 #连接本机mongodb conn=pymongo.Connection() #指定 ...

  3. adb 查看android手机中应用的包名和安装位置

    1. 查看是否连接手机 adb devices 2. 进入指定的device的shell adb shell 或者 adb -s ********* shell 3. adb 查看所有安装的包 pm ...

  4. [JSOI2017]原力

    题目大意: 一个$n(n\le5\times10^4)$个点,$m(m\le10^5)$条边的无向图.每条边有一个边权$w_i(w_i\le10^6)$和一个附加属性$t_i(t_i\in\{R,G, ...

  5. 四. Java继承和多态10. Java Object类

    Object 类位于 java.lang 包中,是所有 Java 类的祖先,Java 中的每个类都由它扩展而来. 定义Java类时如果没有显示的指明父类,那么就默认继承了 Object 类.例如: p ...

  6. Java判断中文字符

    package com.jsoft.test; import java.util.regex.Pattern; /** * 判断中文字符 * * @author jim * @date 2017-12 ...

  7. util.date.js

    ylbtech-JavaScript-util: util.date.js 日期处理工具 1.A,JS-效果图返回顶部   1.B,JS-Source Code(源代码)返回顶部 1.B.1, m.y ...

  8. selfshadow

    realtime rendering v3 page 351 Moire pattern sruface acne artifacts ----------------------- 用 setsta ...

  9. (转)指针的引用(*&)与指针的指针(**)

    本文转载而来,转载出处:http://www.cppblog.com/doing5552/archive/2010/09/28/127994.html 在下列函数声明中,为什么要同时使用*和& ...

  10. Mybatis通用分页

    分页分为真分页和假分页,而 MyBatis 本身没有提供基于数据库方言的分页功能,而是基于 JDBC 的游标分页,很容易出现性能问题.网上提供的一个解决方案感觉还不错,是基于 MyBatis 本身的插 ...