HDU 1398 Square Coins(母函数或dp)
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9903 Accepted Submission(s): 6789
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.
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
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 333
int a[],n,d[N][N]; int main()
{
for(int i=;i<=;i++)
a[i]=i*i;
for(int i=;i<=;i++)
for(int j=;j<=;j++)
d[i][j]=; for(int i=;i<=;i++)
{
for(int j=;j<=&&a[j]<=i;j++)
{
d[i][a[j]]=d[i][a[j-]]+d[i-a[j]][min(a[j],i-a[j])];
d[i][i]=d[i][a[j]];
}
}
int i;
while(cin>>i&&i)
{
cout<<d[i][a[(int)sqrt(i)] ]<<endl;
}
return ;
}
HDU 1398 Square Coins(母函数或dp)的更多相关文章
- 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(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- 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),求用上述货币能使价值 ...
- 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 ...
随机推荐
- luogu2604 [ZJOI2010]网络扩容
先做一遍普通的dinic 然后再更改源点为超级源,超级源向原源加一条capacity=k && cost=0的边,再加上有费用的边跑最小费用最大流 #include <iostr ...
- Python 日期与时间
Python 3.6.4 import time, calendar, datetime print("距离1970年的秒数为:", time.time()) print(&quo ...
- vim第五章 命令行模式
vim第五章命令行模式 技巧 27 结识vim的命令行模式 在命令行模式中执行的命令有被称作ex命令 在按/调出查找提示符或者<C-r>=访问表示寄存器时 命令行模式也被激活 ...
- 图论trainning-part-1 B. A Walk Through the Forest
B. A Walk Through the Forest Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: %I64 ...
- Leetcode 413.等差数列划分
等差数列划分 如果一个数列至少有三个元素,并且任意两个相邻元素之差相同,则称该数列为等差数列. 例如,以下数列为等差数列: 1, 3, 5, 7, 9 7, 7, 7, 7 3, -1, -5, -9 ...
- 利用pytorch复现spatial pyramid pooling层
sppnet不讲了,懒得写...直接上代码 from math import floor, ceil import torch import torch.nn as nn import torch.n ...
- HDU-4848 Wow! Such Conquering! 爆搜+剪枝
Wow! Such Conquering! 题意:一个n*n的数字格,Txy表示x到y的时间.最后一行n-1个数字代表分别到2-n的最晚时间,自己在1号点,求到达这些点的时间和的最少值,如果没有满足情 ...
- vue v-dialogDrag: 弹窗拖拽
Vue.directive('dialogDrag', { inserted:function(el) { const dragDom = el.querySelector('.jsPropupLay ...
- bzoj1063【Noi2008】道路设计
题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1063 用一种划分方式将树划为重链和轻链,使得所有点到根节点的路径经过的轻链最大值最小 sol: ...
- 费用流(bzoj 3130)
Description Alice和Bob在图论课程上学习了最大流和最小费用最大流的相关知识. 最大流问题:给定一张有向图表示运输网络,一个源点S和一个汇点T,每条边都有最大流量.一个合法的网络 ...