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 ...
随机推荐
- kafka生产者消费者
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.Co ...
- 微信自研生产级paxos类库PhxPaxos实现原理介绍
转载自: http://mp.weixin.qq.com/s?__biz=MzI4NDMyNTU2Mw==&mid=2247483695&idx=1&sn=91ea4229 ...
- 多线程(10) — Future模式
Future模式是多线程开发中常用常见的一种设计模式,它的核心思想是异步调用.在调用一个函数方法时候,如果函数执行很慢,我们就要进行等待,但这时我们可能不着急要结果,因此我们可以让被调者立即返回,让它 ...
- Python22之lambda表达式
一.Lambda表达式的概念和意义 lambda表达式有称为隐函数,它的定义过程由形参和要返回的表达式组成,它相对于一般函数而言具有以下优势: 1.免去了函数定义的过程,代码变得更加精简 2.省却函数 ...
- Python后台执行不启用缓存
1.运行时加-u参数,如 # python3 -u test.py >> test.log & 用man查看python的-u参数,说明如下: Force stdin, stdou ...
- Windows上安装配置SSH教程(1)
作者:feipeng8848 出处:https://www.cnblogs.com/feipeng8848/p/8559803.html 本站使用「署名 4.0 国际」创作共享协议,转载请在文章明显位 ...
- js取得对象的类名constructor.name
constructor 属性返回对创建此对象的数组函数的引用. 语法 object.constructor 例子 new Array().constructor//ƒ Array() { [nativ ...
- winform 替换word文档中的字段(包含图片添加),生成导出PDF文件(也可是word文件)
1.先打开你需要替换的word文档,在想要后续更换字段值的地方添加“书签”. 2.将模板文档存放在 程序的Debug文件下. 3.生成文件的按钮点击事件 代码: string templatePath ...
- 这些方面做好了才能叫运营-App运营日常
现在APP的开发推广是时代的潮流,同时也是不少企业的难题.现在我们就来谈谈APP运营的一些问题. 1. 基础运营正常维护产品最日常.最普通的工作,如APP应用包在各大应用市场提交上传等,如安卓渠道,包 ...
- The version of SOS does not match the version of CLR you are debugging
分析dump文件时,由于客户生产环境与分析dump文件的环境不一致,常常会出现下面的错误 The version of SOS does not match the version of CLR yo ...