HDU 1398 Square Coins
来源:互联网 发布:传奇账号数据库 编辑:程序博客网 时间:2024/05/12 13:14
/*
中文翻译:在一个银国度里面,人们不仅有正方形的银币,而且他们的价值观是平方的, 硬币的所有面值的平方不会超过17的平方,如面值为1、4、9.。。。289面值的硬币。有四种支付方式,使总额达到10。
题目大意:求输入一个数,有多少中支付的方式
解题思路:母函数求解
难点详解:由于它是数的平方,所以在求得时候,k应该写成k+=i*i;
关键点:读懂题意,有一点小的升华
解题人:lingnichong
解题时间:2014-08-09 10:16:11
解题感受:注意是写的多少的平方,所以后面写k的变化的时候就要加上i*i。
*/
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8145 Accepted Submission(s): 5531
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.
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
210300
Sample Output
1427
#include<stdio.h>#include<string.h>#define MAXN 300+10int c1[MAXN],c2[MAXN];int main(){int n,i,j,k;while(scanf("%d",&n),n){memset(c2,0,sizeof(c2));for(i=0;i<=n;i++)c1[i]=1;for(i=2;i<=n;i++){for(j=0;j<=n;j++)for(k=0;k+j<=n;k+=i*i)c2[k+j]+=c1[j];for(j=0;j<=n;j++){c1[j]=c2[j];c2[j]=0;}}printf("%d\n",c1[n]);}return 0;}
0 0
- hdu 1398Square Coins
- hdu 1398 Square Coins
- Hdu 1398 - Square Coins
- hdu 1398 Square Coins
- hdu 1398 Square Coins
- hdu 1398 Square Coins
- Square Coins hdu 1398
- hdu 1398 Square Coins
- HDU 1398 Square Coins
- hdu 1398 Square Coins
- hdu 1398 Square Coins
- hdu-1398-Square Coins
- HDU 1398 Square Coins
- hdu 1398 Square Coins
- hdu 1398 Square Coins
- hdu-1398-Square Coins
- HDU-1398 Square Coins
- hdu 1398 Square Coins
- ueditor1.4.3在vs2010项目中,但是发布到iis上却不管用了。
- Jack--10天学会IOS大纲;注意将图片放大观看!
- Android OpenGL ES 开发教程(8):基本几何图形定义
- COCOS2DX中关于labelTTF控件获取不到触摸点的解决办法
- POJ 2288 Islands and Bridges(状态压缩)
- HDU 1398 Square Coins
- 设计模式-目录
- LeetCode_Minimun Path Sum
- codeforces #260 DIV 2 C题Boredom(DP)
- HDU-1754-I Hate It
- CF Round #260 (Div 2)
- ios 常见错误
- ios libxml/tree.h file not found解决办法
- HttpClient入门