Square Coins

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

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,

就只需要改2个地方。 在i遍历表达式时(可以参考我的资料—《母函数详解》),把i<=nNum改成了i*i<=nNum,其次在k遍历指数时把k+=i变成了k+=i*i; Ok,说来说去还是套模板~~~

#include<stdio.h>
#include<string.h>
int c[],temp[];
int main(){
int n;
while(scanf("%d",&n)&&n){
memset(c,,sizeof(c));
memset(temp,,sizeof(temp));
for(int i=;i<=n;i++)
c[i]=;
for(int i=;i*i<=n;i++){
for(int j=;j<=n;j++){
for(int k=;k+j<=n;k+=i*i)
temp[k+j]+=c[j];
} for(int ii=;ii<=n;ii++){
c[ii]=temp[ii];
temp[ii]=; }
}
printf("%d\n",c[n]);
}
return ;
}

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
 

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 (母函数)

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

  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. 杭电ACM hdu 1398 Square Coins

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

  8. hdu 1398 Square Coins【生成函数】

    预处理出完全平方数就和普通的生成函数解整数拆分一样了 #include<iostream> #include<cstdio> using namespace std; cons ...

  9. HDU 1398 Square Coins(DP)

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

随机推荐

  1. Oracle递归 start with...connect by...prior

    prior一侧是父节点 另一侧是子节点 --查询region_id等于4519的节点下面的所有子节点 查找出给定节点的所有子节点 SELECT sr.* FROM spc_region sr wher ...

  2. iOS 语言国际化配置

    所谓的iOS 国际化,就是根据系统不同的语言自动切换. 首先,如图:   创建一个.strings文件,以“Localizable.strings”为文件名:   创建完之后,在XCode的右边勾选自 ...

  3. JS的Ajax对象

    //1.得到对象    var ajax = new XMLHttpRequest(); //2.建立连接    ajax.open('post','./2.php',true); /*       ...

  4. spring boot 搭建基本套路《1》

    1. Spring复习 Spring主要是创建对象和管理对象的框架. Spring通过DI实现了IoC. Spring能很大程度的实现解耦. 需要掌握SET方式注入属性的值. 需要理解自动装配. 需要 ...

  5. pt-online-schema-change 脚本化

    mysql在线更改表可用工具 pt-online-schema-change 更改,或者用gh-ost更改.pt-online-schema-change 在原表创建索引,跟踪新插入的数据.gh-os ...

  6. openresty安装配置 Ubuntu下

    1.进入openresty-1.11.2.4的压缩包木木,我这里是在“/usr/local/”下: 2.进入后执行[tar -xzvf openresty-1.11.2.4.tar.gz]进行解压 3 ...

  7. 前端pc版的简单适配

    我们都知道对于前端pc版本的适配是一个难题,大部分都是做的媒体查询.但是有时间公司不要媒体查询 就是需要不管多大的屏幕都是满屏显示.我就在考虑为啥不用rem给pc端做个适配. 我是基于设计图是1920 ...

  8. Mysql 5.7 开启远程连接

    1 在控制台执行 mysql -uroot -p 系统提示输入数据库root用户的密码,输入完成后即进入mysql控制台 2 选择数据库 mysql -uroot -p use mysql; 开启远程 ...

  9. ElasticSearch 安装配置

    1.   Elasticsearch5.5.2安装 1.1.Elasticsearch安装步骤 #安装之前需安装java 环境,并配置JAVA_HOME环境变量 #直接下载Elasticsearch- ...

  10. (译)JavaScript 中的正则表达式(RegEx)实操——快速掌握正则表达式,伴有随手可练的例子————(翻译未完待续)

    (原文:https://blog.bitsrc.io/a-beginners-guide-to-regular-expressions-regex-in-javascript-9c58feb27eb4 ...