HDU_1398_母函数
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11143 Accepted Submission(s):
7634
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.
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.
single integer representing the number of combinations of coins should be
output. No other characters should appear in the output.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std; int S[];
int c1[];
void cal(int n)
{ int c2[n+];
for(int i=; i<=n; i++)
{
c1[i]=;
c2[i]=;
}
for(int i=; i<=; i++)
{
for(int j=; j<=n; j++)
for(int k=; k+j<=n; k+=i*i)
c2[j+k]+=c1[j];
for(int j=; j<=n; j++)
{
c1[j]=c2[j];
c2[j]=;
}
}
//return c1[n];
} int main()
{
int n;
//for(int i=1;i<=17;i++)
// S[i]=i*i;
cal();
while(scanf("%d",&n)!=EOF&&n)
{
printf("%d\n",c1[n]);
}
return ;
}
HDU_1398_母函数的更多相关文章
- hdu2082 找单词 (母函数)
找单词 题意: 中文题,考虑是不是要写个英文题意..(可惜英语水平不够 囧rz) (题于文末) 知识点: 母函数(生成函数): 生成函数有普通型生成函数和指数型生成函数 ...
- hdu1521 排列组合(指数型母函数)
题意: 有n种物品,并且知道每种物品的数量ki.要求从中选出m件物品的排数. (全题文末) 知识点: 普通母函数 指数型母函数:(用来求解多重集的排列问题) n个元素,其中a1,a2, ...
- Thinkphp的单字母函数整理
有人不太喜欢TP这种单字母函数,其实这也是TP的一个特色,如果理解了这些函数的作用,不管是背,还是写,都是非常方便的,接下来我们以字母顺序开始.A函数 B函数 C函数 D函数 F函数 L函数 R函数 ...
- ThinkPHP单字母函数(快捷方法)使用总结
在ThinkPHP中有许多使用简便的单字母函数(即快捷方法),可以很方便开发者快速的调用,但是字母函数却不方便记忆,本文将所有的字母函数总结一下,以方便以后查找. 1.U() URL组装 支持不同UR ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- [BZOJ3696][FJSC2014]化合物(异或规则下的母函数)
题目:http://hzwer.com/3708.html 分析: 类似树分治思想,设f[x][i]表示以x为根的子树的所有点中,与x的距离为i的点有多少个,这个可以预处理出来 然后我们考虑每颗子树对 ...
- hdu1521 指数型母函数
排列组合 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- UVa12298 Super Poker II(母函数 + FFT)
题目 Source http://acm.hust.edu.cn/vjudge/problem/23590 Description I have a set of super poker cards, ...
- HDU4609 3-idiots(母函数 + FFT)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4609 Description King OMeGa catched three men wh ...
随机推荐
- JavaSE 学习笔记之异 常(十)
异 常: 异常:就是不正常.程序在运行时出现的不正常情况.其实就是程序中出现的问题.这个问题按照面向对象思想进行描述,并封装成了对象.因为问题的产生有产生的原因.有问题的名称.有问题的描述等多个属性信 ...
- 清北学堂模拟赛d5t5 exLCS
分析:比较巧妙的一道题.经典的LCS算法复杂度是O(nm)的,理论上没有比这个复杂度更低的算法,除非题目有一些限制.这道题中两个字符串的长度不一样,f[i][j]如果表示第一个串前i个,第二个串前j个 ...
- poj 1860 bellman 求正环
#include<stdio.h> #include<string.h> #include<queue>//只需判断是否有正环路径就可以了 using namesp ...
- SpringMVC+security
转自:http://blog.csdn.net/bigshotzhang/article/details/12346979 下面我们将实现关于Spring Security3的一系列教程. 最终的目标 ...
- gh-ost 号称是不需要触发器(Triggerless)支持的在线更改表结构的工具
https://segmentfault.com/a/1190000006158503?utm_source=tuicool&utm_medium=referral
- 【转】】}linux awk 命令详解
http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html ----------------------------------- ...
- UVA 10069 Distinct Subsequences(DP)
考虑两个字符串,我们用dp[i][j]表示字串第到i个和字符串到第j个的总数,由于字串必须连续 因此dp[i][j]能够有dp[i][j-1]和dp[i-1][j-1]递推而来,而不能由dp[i-1] ...
- 关于strace的一点东西
好久没写博客了,感觉有点羞愧,认为自己也应该静下心来利用自己可分配的时间去提升自己. 尽管近期在看一些Python的东西,但是认为自己还是不能忘记本行啊,Linux C的一些东西必须一直 ...
- android 自己定义ViewGroup实现可记载并呈现选择的ListView
转载请注明出处:王亟亟的大牛之路 之前也做过一些用TextView之类的记录ListView选项的东西.可是总认为好难看.发现个不错的实现就贴给大家. 项目文件夹 执行效果: 自己定义视图: @Tar ...
- ios 得用代理反向传值
应用场景:有时时候从界面A跳转到界面B,界面B在返回的时候须要将处理的结果传递给A. 实现思路:1,定义一个负责传值的协义,界面A拥有该协义属性,并实现该协义中的方法 2.界面B也拥有该协义属性(代理 ...