HDU-1398-Square Coins(母函数)
链接:
https://vjudge.net/problem/HDU-1398
题意:
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.
思路:
母函数模板, 枚举平方
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
typedef long long LL;
const int INF = 1e9;
const int MAXN = 300+10;
int c1[MAXN], c2[MAXN];
int n;
void Init()
{
c1[0] = 1;
for (int i = 1;i <= 17;i++)
{
for (int j = 0;j < MAXN;j+=i*i)
{
for (int k = 0;k+j < MAXN;k++)
c2[j+k] += c1[k];
}
for (int j = 0;j < MAXN;j++)
{
c1[j] = c2[j];
c2[j] = 0;
}
}
}
int main()
{
Init();
while(~scanf("%d", &n) && n)
{
printf("%d\n", c1[n]);
}
return 0;
}
HDU-1398-Square Coins(母函数)的更多相关文章
- 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)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- HDU 1398 Square Coins 整数拆分变形 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- 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 ...
- HDOJ 1398 Square Coins 母函数
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- 杭电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(DP)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- 038 Android Magicindicator开源框架实现viewpager底部圆形指示器
1.Magicindicator介绍 Magicindicator是一个强大.可定制.易扩展的 ViewPager 指示器框架.是ViewPagerIndicator.TabLayout.PagerS ...
- Quartz.Net—JobBuilder
JobBuilder JobBuilder是一个建造者模式,链式建造.通过静态方法构建一个JobBuilder实例,然后再调用类方法Build()创建一个IJobDetail的实现. 1.静态方法 p ...
- 剑指offer22:从上往下打印出二叉树的每个节点,同层节点从左至右打印。
1 题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 2 思路和方法 使用一个队列存放节点.先将根节点加入到队列中,然后循环遍历队列中的元素,遍历过程中,访问该节点的左右子节点,再将左 ...
- 利用Python进行数据分析 第5章 pandas入门(2)
5.2 基本功能 (1)重新索引 - 方法reindex 方法reindex是pandas对象地一个重要方法,其作用是:创建一个新对象,它地数据符合新地索引. 如,对下面的Series数据按新索引进行 ...
- 07 IO流(四)——文件字节流 FileInputStream/FileOutputStream与文件的拷贝
两个类的简述 专门用来对文件进行读写的类. 父类是InputStream.OutputStream 文件读入细节 FileOutputStream流的构造方法:new FileOutputStream ...
- TCP--粘包拆包,netty的解决方式
TCP基于链接的协议,并且保证有序性. 但是,每个包的长度,需要明确,否则会发生粘包现象. 以下示例为一个自定义协议的例子,其中包含了拆包的内容. 所有的类: 协议类: public class Pe ...
- C# 阿拉伯数字转换为中文数字/中文数字转换为阿拉伯数字
项目中经常会格式化数据,转换数字的使用情况比较多,记录一下数字转换的方法! 如果需要转换为繁体中文,将数组里的汉字换成繁体中文即可. 1.阿拉伯数字转换为中文数字 /// <summary> ...
- J.U.C之Condition
此篇博客所有源码均来自JDK 1.8 在没有Lock之前,我们使用synchronized来控制同步,配合Object的wait().notify()系列方法可以实现等待/通知模式.在Java SE5 ...
- 基于【 建造者模式】一 || 网关zuul过滤器封装
一.springcloud的zuul网关拦截 1.黑名单拦截 2.参数验签 3.Api接口权限验证 二.网关拦截实现方式 1.继承ZuulFilter方法,实现业务逻辑 @Component @Slf ...
- ceph集群部署(基于jewel版)
环境 两个节点:ceph1.ceph2 ceph1: mon.mds.osd.0.osd.1 ceph2: osd.2.osd.3 网络配置: ceph1: 管理网络,eth0,10.0.0.20 存 ...