链接:

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(母函数)的更多相关文章

  1. hdu 1398 Square Coins (母函数)

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

  2. 题解报告:hdu 1398 Square Coins(母函数或dp)

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

  3. HDU 1398 Square Coins 整数拆分变形 母函数

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  4. HDU 1398 Square Coins(母函数或dp)

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

  5. hdu 1398 Square Coins 分钱币问题

    Square Coins Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  6. hdu 1398 Square Coins(生成函数,完全背包)

    pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...

  7. hdu 1398 Square Coins(简单dp)

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

  8. HDOJ 1398 Square Coins 母函数

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

  9. 杭电ACM hdu 1398 Square Coins

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

  10. HDU 1398 Square Coins(DP)

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

随机推荐

  1. C++_对象数组与对象指针

    对象数组与对象指针 1. 对象数组 所谓对象数组是指每一数组元素都是对象的数组, 也就是说,若一个类有若干个对象,则把这一系列的对象用一个数组来存放. 对象数组的元素是对象, 不仅具有数据成员,而且还 ...

  2. ~json库的使用

    一.json简介 json全称"JavaScript Object Notation"(JavaScript对象表示法)它是一种基于文本,独立于语言的轻量级数据交换格式.易于让人阅 ...

  3. 机器学习之softmax回归笔记

    本次笔记绝大部分转自https://www.cnblogs.com/Luv-GEM/p/10674719.html softmax回归 Logistic回归是用来解决二类分类问题的,如果要解决的问题是 ...

  4. git出现Invalid path

    今天换了电脑,我直接把整个仓库从电脑A复制到了电脑B,包括仓库下面的 .git 文件夹. 修改代码后我执行了一下 git add . 出现了一个报错 fatal: Invalid path 'D:/S ...

  5. 本地安装SQL Server 2017 Express和Microsoft SQL Server Management Studio 18.1

    sqlserver下载链接:https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 这个安装的是免费版的Express,当然也可 ...

  6. R_数据视觉化处理_初阶_02

    通过数据创建一幅简单的图像, #Crate a easy photopdf("mygraph.pdf") attach(mtcars) plot(wt,mpg) abline(lm ...

  7. Django Rest framework的限流实现流程

    目录 一 什么是throttle 二 Django REST framework是如何实现throttle的 三 Django REST framework中throttle源码流程 一 什么是thr ...

  8. Ext之页面多次请求问题(下拉框发送无关请求)

    extjs 下拉框在拉取本地数据,然后又要展示后台数据时,出现过此问题(加载页面,自动发送无关的请求导致后台出现错误日志) { xtype:'combo', id:'state', width:130 ...

  9. iOS开发-NSArray

    忙了一上午,解决了几个bug,现在终于抽出来一点时间喝点水休息下, 想着系列这么浩大的一个工程,才刚刚开始写,不能断了,就跟写小说一样,既然是系列,那么就需要不停更... 好吧. 简单的说说iOS开发 ...

  10. Vue父组件像子组件传值--自定义属性

    这里有个注意的地方,Vue实例控制app DIV 大组件,我们在div中天加小组件的时候,传值需要创建自定义的属性 之后在通过props:[‘属性名’] 来把父元素data中的数据传递给子组件 < ...