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. 一直困扰设计师多年的Android 单位 dp

    轻松理解Android开发单位DP ,让设计与开发高度匹配,整合了网上各大资料汇总一个通俗易懂的. 一直困扰设计师多年的Android 单位 dp 设计这么多年了,相信很多设计师,一直被DP搞得晕头转 ...

  2. linux usb信息查看与调试

    lsusb cat /sys/kernel/debug/usb/devices T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12   M ...

  3. [Android Pro] Swift 3.0多线程

    本文只介绍Grand Central Dispath(GCD) 中央调度 个人认为一个GCD就够用了,可能是改版或是其他的在找之前写的多线程方法时发现不能用了,看文档之后发现改了,现在看上去更加简单易 ...

  4. Python 3.6学习笔记(一)

    知识是一座宝库,而实践就是开启这座宝库的钥匙. ----Thomas Fuller 开始之前 基础示例 Python语法基础,python语法比较简单,采用缩紧方式. # print absolute ...

  5. [leetcode]Convert Sorted Array to Binary Search Tree @ Python

    原题地址:http://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ 题意:将一个排序好的数组转换为一颗二叉 ...

  6. Same Tree leetcode java

    题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

  7. 巧妙利用函数的惰性载入提高javascript 代码性能

    在 javascript 代码中,因为各浏览器之间的行为的差异,我们经常会在函数中包含了大量的 if 语句,以检查浏览器特性,解决不同浏览器的兼容问题. 例如,我们最常见的为 dom 节点添加事件的函 ...

  8. kafka基本原理概述——patition与replication分配

    kafka一直在大数据中承受着数据的压力也扮演着对数据维护转换的角色,下面重点介绍kafka大致组成及其partition副本的分配原则: 文章参考:http://www.linkedkeeper.c ...

  9. CentOS 7 中 hostnamectl 的使用

    hostnamectl 是在 centos7 中新增加的命令,它是用来修改主机名称的,centos7 修改主机名称会比以往容易许多. 用法 # hostnamectl -h -h --help 显示帮 ...

  10. GIT 恢复已删除的提交

    在Git中一切的操作都是可以恢复的,包括已经删除的提交,今天在做一个项目时就遇到了这种问题,也不知道是怎么回事不小心就把上午提交的所有代码都删除了,于是赶紧通过git log来查看日志,但奇怪的是当时 ...