Square CoinsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total Submission (s): 8891 Accepted Submission (s): 6067
Problem descriptionpeople in Silverland use square coins. Not only they has square shapes but also their values is 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, is available in Silverland.
There is four combinations of coins to pay ten credits:
Ten 1-credit coins,
One 4-credit coin and six 1-credit coins,
4-credit coins and 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.
Inputthe input consists of lines each containing an integer meaning an amount to being paid, followed by a line containing a Zero. You may assume the amounts is positive and less than 300.
Outputfor 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
Sourceasia 1999, Kyoto (Japan) is just an exponential change, or a simple parent function template.
Investigating knowledge points: the transformation of the parent function template--the power of the square #include <stdio.h>int c1[330],c2[330]; int main () {int n;while (~scanf ("%d", &n), n) {int i,j,k;for (i=0;i<=n;++i) {c1[i]=1;c2[i]=0;} for (I=2;i<=n;++i) {for (j=0;j<=n;++j) {for (k=0;k+j<=n;k+=i*i)//The only change of common parent function {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;}
(Square power female function) hdu 1398 square Coins