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 ... 
随机推荐
- 原 jmeter中类似lr的场景设置
			有一天如果你们领导来一句给我测下这个首页到底能扛多少并发,并发量极限是多少,这时你不要慌不要忙,拿出jmeter神器,设置下场景,目标设置成1000,每10秒启动100个并发,等着看什么时候系统响应开 ... 
- SQLserver查看某个视图的创建语句
			1.已经创建好的视图,查看视图创建时的源码 sp_helptext '视图名' 如下: sp_helptext 'V_user' 方式2: sa账户登录SQLserver,选择视图---右键---- ... 
- PHP 接入支付宝即时到账功能
			首先请到支付宝那边申请一个及时到账的接口账户,需要提交相关材料申请.然后根据即时到账的API文档进行接入.API文档提供了各种语言版本的demo,我这里是下的php版demo,然后再进行相关修改操作. ... 
- Codeforces Round #390 (Div. 2) A+B+D!
			A. Lesha and array splitting 水题模拟.(0:10) 题意:给你一个n个元素的数组,求能否把这个数组分成若干连续小段,使得每段的和不为0.如有多种解输出任意一个. 思路:搞 ... 
- PTA 10-排序5 PAT Judge   (25分)
			题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge (25分) The ranklist of PA ... 
- 九度oj 题目1254:N皇后问题
			题目描述: N皇后问题,即在N*N的方格棋盘内放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在同一斜线上.因为皇后可以直走,横走和斜走如下图). 你的任务是,对 ... 
- BZOJ 1226 [SDOI2009]学校食堂Dining ——状压DP
			看到B<=8,直接状态压缩即可. dp[i][j][k]表示当前相对位置是关于i的,并且i以前的已经就餐完毕,j表示i和之后的就餐情况,k表示上一个就餐的人的相对位置. 然后Dp即可 #incl ... 
- BZOJ 3926 [Zjoi2015]诸神眷顾的幻想乡 ——广义后缀自动机
			神奇的性质,叶子节点不超过20个. 然后把这些节点提出来构成一颗新树,那么这些树恰好包含了所有的情况. 所以直接广义后缀自动机. 然后统计本质不同的字符串就很简单显然了. #include <c ... 
- [luoguP2324] [SCOI2005]骑士精神(A*?)
			传送门 蒟蒻并不懂A*是什么,但是题解里有个Astar 可以看出,当前棋盘和最终的棋盘如果有k个不同的,那么至少需要k-1步来移动 所以如果 当前步数 + k - 1 > limit 就直接退出 ... 
- 洛谷 [P1995] 程序自动分析
			并查集+ 离散化 首先本题的数据范围很大,需要离散化, STL离散化代码: //dat是原数据,id是编号,sub是数据的副本 sort(sub + 1, sub + tot + 1); size = ... 
