Square Coins[HDU1398]
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6746 Accepted Submission(s): 4554
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
Asia 1999, Kyoto (Japan)
Recommend
Ignatius.L
#include<stdio.h>
#include<string.h>
int p[],tmp[];
void prepare()
{
int i,j,k;
for (i=;i<=;i++) p[i]=;
for (i=;i<=;i++)
{
memset(tmp,,sizeof(tmp));
for (j=;j<=;j++)
for (k=;k<=;k+=i*i)
tmp[j+k]+=p[j];
for (j=;j<=;j++) p[j]=tmp[j];
}
}
int main()
{
prepare();
int n;
while (scanf("%d",&n)!=EOF)
{
if (n==) return ;
printf("%d\n",p[n]);
}
return ;
}
Square Coins[HDU1398]的更多相关文章
- HDU1398 Square Coins(生成函数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- HDU1398 Square Coins
Description People in Silverland use square coins. Not only they have square shapes but also their v ...
- HDU1398:Square Coins(DP水题)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- HDOJ 1398 Square Coins 母函数
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- Square Coins(母函数)
Square Coins 点我 Problem Description People in Silverland use square coins. Not only they have square ...
- HDU 1398 Square Coins 整数拆分变形 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- 杭电ACM hdu 1398 Square Coins
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
随机推荐
- Unity 3D 关于给APK包加广告的流程
http://hunterwang.diandian.com/post/2012-11-23/40042217286 最近一直纠结着用Unity给安卓的应用添加广告,用Unity3d做安卓我还是第一次 ...
- 浅谈B树
B树即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right): 2.所有结点存储一个关键字: 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树: 如: ...
- MVC NonAction属性
3.1. NonAction属性 若将NonAction属性应用在Controller中的Action方法上,即使该Action方法是公共方法,也会告知ActionInvoker不要选取这个Actio ...
- iOS 中的第三方库管理工具
xcode没有android studio中的gradle进行第三方库管理,但是有第三方的库管理工具CocoaPods,https://github.com/CocoaPods/CocoaPods/w ...
- mysql 源码下载列表
2013年11月16日 14:57:04 http://download.softagency.net/MySQL/Downloads/MySQL-5.5/ http://code.google.co ...
- (原创)Python文件与文件系统系列(2)——os模块对文件、文件系统操作的支持
os模块的功能主要包括文件系统部分和进程管理部分,这里介绍其中与文件系统相关的部分. 当请求操作系统执行操作失败时,os模块抛出内置异常 exceptions.OSError 的实例,可以通过 os. ...
- Java for LeetCode 046 Permutations
Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the follo ...
- CodeForces - 417E(随机数)
Square Table Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- 利用TabWidget实现底部菜单
TabWidget类似于通话记录的界面,通过切换多个标签从而显示出多个不同内容,能够展示内容丰富的页面信息,而且彼此之间不会干扰,有利于展示.下面,通过一个例子来学习用法 首先用一个类来继承TabAc ...
- 开启InnoDB每表一个独立的表空间
mysql> show variables like '%innodb%'; +---------------------------------+----------------------- ...