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. SpringBoot学习16:springboot整合junit单元测试

    1.创建maven项目,修改pom.xml文件 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springfram ...

  2. orcal 数据库 maven架构 ssh框架 的全注解环境模版 maven中央仓库批量删除lastupdated文件后依然是lastupdated解决方法 mirror aliyun中央仓库

    批量删除文件,得用批处理文件,文件名随便,路径改成你的Repository,代码如下 rem 这里写你的仓库路径 set REPOSITORY_PATH=d:\repo rem 正在搜索... for ...

  3. css3圆角矩形、盒子阴影

    css3圆角矩形 div{ width: 200px; height: 200px; border: #f00 solid 1px; margin-bottom: 10px; } 1.设置 borde ...

  4. Mysqldump自定义导出n条记录

    很多时候DBA需要导出部分记录至开发.测试环境,因数据量需求较小,如果原库的记录多,且表数量也多,在用mysqldump命令导出时可以添加一个where参数,自定义导出n条记录,而不必全量导出. 示例 ...

  5. PHP icov转码报错解决方法,iconv(): Detected an illegal character in input string

    iconv(): Detected an illegal character in input string 错误解决方法 //转码 function iconv_gbk_to_uft8($strin ...

  6. Matplotlib 图表的样式参数

    1. import numpy as np import pandas as pd import matplotlib.pyplot as plt % matplotlib inline # 导入相关 ...

  7. HDU暑假多校第八场J-Taotao Picks Apples

    一.题意 给定一个序列,之后给出若干个修改,修改的内容为在原序列的基础上,将某一位元素的值改成给定的值<每次修改相互独立,不保存修改后的结果>.之后询问,在选择第一位元素的情况下,最长递增 ...

  8. python2.7练习小例子(十六)

    16):题目:输入一行字符,分别统计出其中英文字母.空格.数字和其它字符的个数.     程序分析:利用 while 或 for 语句,条件为输入的字符不为 '\n'.     程序源代码: #!/u ...

  9. MVC中Session的使用和传递

    1.登录时在controller中记录session,代码如下: public ActionResult Login(UserLoginViewModel uViewModel) { if (Mode ...

  10. 北京Uber优步司机奖励政策(3月25日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...