Square Coins

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

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   |   We have carefully selected several similar problems for you:  2152 2082 2079 2069 2110 
 

母函数入门题

 //0MS    200K    615 B    G++
#include<stdio.h>
#define N 305
int c1[N],c2[N];
int _n[]={,,,,,,,,,,,,,,,,};
int fun(int n)
{
int i,j,k;
for(i=;i<=n;i++){
c1[i]=;
c2[i]=;
}
for(i=;i<;i++){
for(j=;j<=n;j++)
for(k=;k+j<=n;k+=_n[i])
c2[j+k]+=c1[j];
for(j=;j<=n;j++){
c1[j]=c2[j];
c2[j]=;
}
}
return c1[n];
}
int main(void)
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n==) break;
printf("%d\n",fun(n));
}
return ;
}

hdu 1398 Square Coins (母函数)的更多相关文章

  1. 题解报告:hdu 1398 Square Coins(母函数或dp)

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  2. HDU 1398 Square Coins 整数拆分变形 母函数

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  3. HDU 1398 Square Coins(母函数或dp)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  4. hdu 1398 Square Coins 分钱币问题

    Square Coins Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

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

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

  6. hdu 1398 Square Coins(简单dp)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Pro ...

  7. HDOJ 1398 Square Coins 母函数

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  8. 杭电ACM hdu 1398 Square Coins

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  9. HDU 1398 Square Coins(DP)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

随机推荐

  1. mysql数据库常规命令操作

    1.MySQL数据库导出命令 1.导出整个数据库 mysqldump -u 用户名 -p 数据库名 > 导出的文件名     mysqldump -u wcnc -p smgp_apps_wcn ...

  2. 在virtualbox(win7)下使用USB摄像头

    解决方法: 去https://www.virtualbox.org/wiki/Downloads下载VirtualBox 4.3.8 Oracle VM VirtualBox Extension Pa ...

  3. HsqlDB Demo

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sq ...

  4. python subprocess.Popen 非阻塞

    1.非阻塞设置subprocess.Popen(args, stdout=subprocess.PIPE,stderr=subprocess.PIPE) def non_block_read(outp ...

  5. Bay Trail平板安装Ubuntu ThinkPad 8(20BNA00RCD)

    首先说下没搞定的事项: 1,grub不能启动w10 2,ubuntu不能检测到无线网卡硬件 3,ubuntu更新软件和语言支持时,unpacking文件时经常都会发生卡死(怀疑是emmc驱动的问题) ...

  6. arcgis_engine_develop_error_42

    解决: 今天在VS2013打开程序时,手工添加了pageLayoutControl隔一会弹出错误窗口:Provide your license server administrator with th ...

  7. jquery操作复选框(checkbox)的12个小技巧总结

    1.获取单个checkbox选中项(三种写法)$("input:checkbox:checked").val()或者$("input:[type='checkbox']: ...

  8. java SE编写图形应用程序

    借鉴了java 核心技术卷1    并参考http://www.jb51.net/article/56158.htm 添加了JTextField的使用. ####################### ...

  9. CoIDE在STM32系列单片机中的使用实践

    这一段时间找到CoIDE,发现其真的挺好用,编辑界面比Keil功能强大.因此把实际操作过程记录下来. CoIDE  是CooCox专业打造的一款免费的ARMCortexMCU嵌入式集成开发环境(Int ...

  10. Mac下命令行中用sublime打开指定文件 设置方法

    sublime2版本 官网提供的方法:sublime2 官网提供的方法是:ln -s "/Applications/Sublime Text 2.app/Contents/SharedSup ...