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. Android开发-无法新建Activity及新建后编译错误

    下载了其他的工程后,新建Activity时无法进行下一步,报错:“This template requires a minimum SDK version of at least 7, and the ...

  2. python转exe的小工具

    其实只是在cxfreeze的基础上加了个壳,做成窗口软件了 使用了pyqt做的界面,软件发布在了开源中国上,可以直接去下面的地址查看 http://git.oschina.net/robocky/py ...

  3. Matlab中的一些小技巧

    (转于它处,仅供参考) 1.. Ctrl+C 中断正在执行的操作 如果程序不小心进入死循环,或者计算时间太长,可以在命令窗口中使用Ctrl+c来中断.MATLAB这时可能正疲于应付,响应会有些滞后. ...

  4. cx_Oracle 中文乱码问题解决

    设置NLS_LANG环境变量 import os os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'

  5. QNDataSet打印预览自动关闭问题

    问题:打印预览后,数据集自动关闭 解决: TQNDataSet = class(TFDMemTable) private protected procedure PSReset; override; ...

  6. teeChart 修改注册表实现无试用到期提示

    teechart在注册表的跟目录为HKEY_CLASSES_ROOT\CLSID,以下的子目录会根据版本的不同发生改变,但是最底级的目录是TypeLib(例如[HKEY_CLASSES_ROOT\CL ...

  7. python-etcd

    Client 对象 ['_MDELETE', '_MGET', '_MPOST', '_MPUT', '__class__', '__contains__', '__del__', '__delatt ...

  8. Hibernate一对一外键双向关联(Annotation配置)

    如上图所示:一个学生有一个学生证号,一个学生证号对应一名学生.在Hibernate中怎么用Annotation来实现呢? 学生类,主键是id:学生证的主键也是Id: Student.java pack ...

  9. 深入了解jQuery之整体架构

    本文是在阅读了Aaron艾伦的jQuery源码解析(地址:http://www.imooc.com/learn/172)后的个人体会以及笔记.在这里感谢艾伦老师深入浅出的讲解!! 先来看看如何生成一个 ...

  10. react使用过程记录

    1, webpack使用,如果发现浏览器打不开,检查是不是 端口冲突 2, webpack报错,如下,加粗是不是 lodash加载的问题 >> A special character wa ...