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 ...
随机推荐
- UCloud 的安全秘钥
UCloud 的安全秘钥(困难) 1200ms 262144K 每个 UCloud 用户会构造一个由数字序列组成的秘钥,用于对服务器进行各种操作.作为一家安全可信的云计算平台,秘钥的安全性至关重要.因 ...
- (39.3) Spring Boot Shiro权限管理【从零开始学Spring Boot】
在学习此小节之前您可能还需要学习: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...
- Java_集合总结
集合分类 Collection 接口是集合的父类 1.Set 集合 使用内部的排列机制(无序),存入集合的顺序和取出集合的顺序不一致,没有索引,存入集合的元素没有重复 HashSet集合 Linked ...
- 洛谷 P1851 好朋友
题目背景 小可可和所有其他同学的手腕上都戴有一个射频识别序列号码牌,这样老师就可以方便的计算出他们的人数.很多同学都有一个“好朋友” .如果 A 的序列号的约数之和恰好等于B 的序列号,那么 A的好朋 ...
- noip模拟赛 时之终末
题目背景 圣乔治:不用拘泥,剩下的时间已不多…… 圣乔治:直呼我的真名—— 丝佩碧雅:圣乔治大人 圣乔治:如今,已无法维持结界,或是抑制深渊的前进 圣乔治:既然如此,我将献上这副身躯,期望最后的战斗 ...
- springCloud学习-消息总线(Spring Cloud Bus)
1.简介 Spring Cloud Bus 将分布式的节点用轻量的消息代理连接起来.它可以用于广播配置文件的更改或者服务之间的通讯,也可以用于监控.本文要讲述的是用Spring Cloud Bus实现 ...
- pthread2
下面我们来看看这个demo #include <stdio.h> #include <pthread.h> #include <unistd.h> #include ...
- 利用jQuery设计横/纵向菜单
在网页中,菜单扮演着"指路者"的角色.怎样设计一个人性化的菜单呢.以下小编带着大家一起做. 效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi ...
- jsp页面中使用javascript获取后台放在request或session中的值
在JSP页面中.常常使用javascript,可是要出javascript获取存储在request,session, application中的值.例如以下是获取request中的值: 如果后台中有: ...
- java中statickeyword
1.static变量 依照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:还有一种是没有被static修饰的变量,叫实例变量. 两者的差别是: 对于静态变量 ...