HDU 1398 Square Coins 整数拆分变形 母函数
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9728 Accepted Submission(s): 6668
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,
#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 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.
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.
10
30
0
4
27
HDU 1398 Square Coins 整数拆分变形 母函数的更多相关文章
- 题解报告:hdu 1398 Square Coins(母函数或dp)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- HDU 1398 Square Coins(母函数或dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins 分钱币问题
Square Coins Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- hdu 1398 Square Coins(生成函数,完全背包)
pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- 杭电ACM hdu 1398 Square Coins
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- hdu 1398 Square Coins【生成函数】
预处理出完全平方数就和普通的生成函数解整数拆分一样了 #include<iostream> #include<cstdio> using namespace std; cons ...
- HDU 1398 Square Coins(DP)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- SpringCloud微服务实战:一、Eureka注册中心服务端
1.项目启动类application.java类名上增加@EnableEurekaServer注解,声明是注册中心 1 import org.springframework.boot.SpringAp ...
- Nacicat for Oracle 绿色版 亲测可用
参考: http://blog.csdn.net/u013107634/article/details/52741591 https://blog.csdn.net/zhengyikuangge/ar ...
- iOS 直播类APP开发流程解析
1 . 音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放显示1.数据采集:摄像机及拾音器收集视频及音频数据,此时得到的为原始数据涉及技术或协议:摄像机:CCD.C ...
- Debug实验学习汇编
R命令查看.改变CPU寄存器的内容: D命令查看内存中的内容: E命令改写内存中的内容: U命令将内存中的机器指令翻译成汇编指令: T命令执行一条机器指令: A命令以汇编指令的格式在内存中写入一条机器 ...
- MySQL实现序列自增
#创建序列表 DROP TABLE IF EXISTS `sequence`; CREATE TABLE `sequence` ( `name` ) NOT NULL COMMENT '序列名称', ...
- I/O流、文件操作
1)操作文件 Path和Files是在JavaSE7中新添加进来的类,它们封装了在用户机器上处理文件系统所需的所有功能.Path表示的一个目录名序列,其后还可以跟着一个文件名.路径中的第一个参数可以是 ...
- 20190105-打印字母C,H,N,口等图像和杨辉三角
1. 打印字母C ****** * * * * ****** def print_c(n): print('*' * n) for i in range(n): print('* ') print(' ...
- python-集合类型
集合具有唯一性(集合中的元素各不相同),无序性,确定性(集合中的元素是不可改变的,不能是列表,字典以及集合本身) 1.add(self, *args, **kwargs),union(self, *a ...
- django序列化时间
具体代码: import json,time,datetime lis ={'time':datetime.date.today(),"username":"zhilei ...
- 预装win8的笔记本如何重装win7
测试电脑联想T440. 开机按F1,然后Enter,进入Bios设置. 先关闭Secure Boot,然后设置为Legacy Boot. 之后才能设置U盘为第一启动盘. 进入老毛桃的PE系统,使用Di ...