http://acm.hdu.edu.cn/showproblem.php?pid=1398

Square Coins

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6697    Accepted Submission(s): 4521

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
2 10 30 0
 
Sample Output
1 4 27
 
Source
 
Recommend
Ignatius.L
 母函数.......
 #include<iostream>
using namespace std;
int main()
{
int n,i,j,k;
while(cin>>n,n)
{
int c1[]={},c2[]={};
for(j=;j<=n;j++)
{
c1[j]=;
}
for(i=;i*i<=n;i++)
{
for(j=;j<=n;j++)
{
for(k=;k+j<=n;k+=i*i)
{
c2[k+j]+=c1[j];
}
}
for(j=;j<=n;j++)
{
c1[j]=c2[j];
c2[j]=;
}
}
cout<<c1[n]<<endl;
}
return ;
}

HDUOJ ------1398的更多相关文章

  1. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  2. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  3. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

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

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

  5. hdu-oj 1874 畅通工程续

    最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...

  6. C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...

  7. C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...

  8. 【BZOJ 1398】 1398: Vijos1382寻找主人 Necklace (最小表示法)

    1398: Vijos1382寻找主人 Necklace Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 308  Solved: 129 Descrip ...

  9. [hdu 1398]简单dp

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1398 看到网上的题解都是说母函数……为什么我觉得就是一个dp就好了,dp[i][j]表示只用前i种硬币 ...

随机推荐

  1. jQuery2.0应用开发:SSH框架整合jQuery2.0实战OA办公自己主动化(VSS、operamasks-UI框架)

    我的qq是2059055336,对这个课程有兴趣的能够加我qq联系. 一.本课程是怎么样的一门课程(全面介绍)    1.1.课程的背景 jQuery 2.0 正式版公布.不在支持 IE 6/7/8  ...

  2. [Android Pro] AtomicInteger的用法

    J2SE 5.0提供了一组atomic class来帮助我们简化同步处理.基本工作原理是使用了同步synchronized的方法实现了对一个long, integer, 对象的增.减.赋值(更新)操作 ...

  3. 【HDOJ】【1964】Pipes

    插头DP 做完Formula 1以后这就是傻逼题了……直接将“数路径方案数”改为“计算路径长度取最小值”即可,没多大难度 都不用判当前格子是否能够到达的……不过!外边的一圈“墙”还是要加的!不然会有冗 ...

  4. ComboxEdit 重要属性

    DisplayMember="ComboItemName" ValueMember="ComboItemCode"IsTextEditable="Tr ...

  5. Windows上使用“LogView”打开大文件

    最近因为工作需要要打开一个300+MB的文件,试过了N个编辑器不是打不开就是软件直接挂掉或是占用内存太大,已经严重影响了我的工作 还好在网络上找到老外写的一个免费软件,官网上说是可以打开4G+的文件( ...

  6. ios之开发者须知常见简写英文代表的含义

    <span style="white-space:pre"> </span> //NS基本 //MK地图 //CG图形绘制 //AV视音频 //UI视图 / ...

  7. YOURLS' API

    YOURLS' API 特征 生成或获取现有的短URL,带有顺序关键字或自定义关键字获取一些关于你的链接的统计信息:点击链接,点击最少的链接,最新链接输出格式:JSON.XML或简单的原始文本Auth ...

  8. Python标记去重

    预逻辑脚本代码: uniqueList = [] def isDuplicate(inValue): if inValue in uniqueList: return 1 else: uniqueLi ...

  9. PowerDesigner P M F 的意思

    M:表示强制非空:P:是否为主键:D:是否在模型中显示.gerenate:表示是否作为表生成

  10. Android获取网络图片应用示例

    1.养成好习惯,配置字符串资源文件 strings.xml <?xml version="1.0" encoding="utf-8"?> <r ...