Square Coins

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

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
 
题意:
有17种硬币面值为1,4,9,16.......17^2,给出一个值问有多少种组成方法。
代码:
 //模板
#include<bits\stdc++.h>
using namespace std;
int c1[],c2[];
void init()
{
for(int i=;i<=;i++)
{
c1[i]=;
c2[i]=;
}
for(int i=;i*i<=;i++)
{
for(int j=;j<=;j++)
for(int k=;j+k<=;k+=i*i)
c2[j+k]+=c1[j];
for(int j=;j<=;j++)
{
c1[j]=c2[j];
c2[j]=;
}
}
}
int main()
{
int n;
init();
while(scanf("%d",&n)&&n)
{
printf("%d\n",c1[n]);
}
return ;
}

*HDU 1398 母函数的更多相关文章

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

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

  2. hdu 1028 母函数 一个数有几种相加方式

    ///hdu 1028 母函数 一个数有几种相加方式 #include<stdio.h> #include<string.h> #include<iostream> ...

  3. hdu 1398 Square Coins 分钱币问题

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

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

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

  5. hdu 1398 Square Coins (母函数)

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

  6. HDU 1028 HDU 1398 (母函数)

    题意:输入一个n  给出其所有组合数 如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 重复不算 母函数入门题 ...

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

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

  8. HDU 1398 Square Coins 平方硬币 (普通母函数,水)

    题意: 有17种硬币,每种的面值为编号的平方,比如 1,4,9,16.....给出一个数字,求组成这个面值有多少种组法? 思路: 用普通母函数解,主要做的就是模拟乘法,因为硬币是无限的,所以每个构造式 ...

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

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

随机推荐

  1. centos系统/etc/sysconfig/目录下无iptables文件

    原因一般是没有配置过防火墙,在安装linux系统时也已经禁掉了防火墙 随便写一条iptables命令配置个防火墙规则:如: iptables -P OUTPUT ACCEPT 然后用命令:servic ...

  2. Android安全攻防战,反编译与混淆技术完全解析(下)

    在上一篇文章当中,我们学习了Android程序反编译方面的知识,包括反编译代码.反编译资源.以及重新打包等内容.通过这些内容我们也能看出来,其实我们的程序并没有那么的安全.可能资源被反编译影响还不是很 ...

  3. debian8安装Odoo中的Barcode Scanner Hardware Driver模块时,提示没有evdev

    解决方法: $ apt-get install python-dev python-pip gcc $ apt-get install linux-headers-$(uname -r) $ sudo ...

  4. jquery计算文本字符个数

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  5. 文件上传之 HttpPostedFile

    HttpPostedFile类,提供对客户端已上载的单独文件的访问. 公共属性如下: SaveAs()方法,用于保存上传文件的内容. 用法为: #region 文件上传 /// <summary ...

  6. 禁止换行“white-space:nowrap;”!

    "white-space:nowrap;" <html> <div class="box">精彩的生活,精彩的世界</div> ...

  7. 多Linux系统如何复用/home目录

    Brief: 1./home单独分区:2.不同系统/home建立不同的用户名:3.不同系统/home对其他用户授权 Linux下/home文件夹可以通用吗?例如我机器上同时装了两个Linux系统,可以 ...

  8. eclipse控制台乱码

  9. DirectX9 Sample_Empty Project

    作为第一个程序,EmpytProject仅仅示范了如何绑定DXUTstate结构中的回调函数. 回调函数 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函数,当 ...

  10. Unity3D 脚本编译器无法关联VisualStudio2012解决办法

    开发环境:Win8 + Unity 4.34f1 +Visual Studio2012 旗舰版 解决办法:   1.创建一个start.bat文件,内容为:[start "" %* ...