HDU1398 Square Coins
Description
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.
10
30
0
一个很标准的母函数题目,唯一需要改变的就是把+i写成+i*i 因为题意是平方倍的增加
#include<stdio.h>
#include<iostream>
using namespace std;
int n;
int a[],b[];
int main()
{
while(cin>>n)
{ if(n==) break;
for(int i=;i<=n;i++)
{
a[i]=;
b[i]=;
}
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
for(int k=;k+j<=n;k+=i*i)
{
b[k+j]+=a[j];
}
}
for(int z=;z<=n;z++)
{
a[z] = b[z];
b[z] = ;
}
}
cout<<a[n]<<endl;
}
return ;
}
HDU1398 Square Coins的更多相关文章
- HDU1398 Square Coins(生成函数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- HDU-1398 Square Coins(生成函数)
题意 与$hdu1028$类似,只不过可用的数字都是平方数. 思路 类似的思路,注意下细节. 代码 #include <bits/stdc++.h> #define DBG(x) cerr ...
- hdu1398 Square Coins(母函数)
题目类似于整数拆分,很明显用母函数来做. 母函数的写法基本固定,根据具体每项乘式的不同做出一些修改就行了.它的思路是从第一个括号开始,一个括号一个括号的乘开,用c1数组保存之前已经乘开的系数,即c1[ ...
- Square Coins[HDU1398]
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- HDU1398: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: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- HDOJ 1398 Square Coins 母函数
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- Square Coins(母函数)
Square Coins 点我 Problem Description People in Silverland use square coins. Not only they have square ...
随机推荐
- 探索Web Office Apps服务
老样子,先放几个官链: WOA部署规划:http://technet.microsoft.com/zh-cn/library/jj219435(v=office.15).aspx 拓扑规划:http: ...
- JAVA基础知识总结14(String、StringBuffer、StringBuilder)
1.String字符串: java中用String类进行描述.对字符串进行了对象的封装.这样的好处是可以对字符串这种常见数据进行方便的操作.对象封装后,可以定义N多属性和行为. 如何定义字符串对象呢? ...
- 机器人自主移动的秘密:实际应用中,SLAM究竟是如何实现的?(二)
博客转载自:https://www.leiphone.com/news/201612/FRzmoEI8Iud6CmT2.html 雷锋网(公众号:雷锋网)按:本文作者SLAMTEC(思岚科技公号sla ...
- 1054D&EZOJ #93 Changing Array
传送门 分析 我们可以对一个数列求前缀和,如果pre[l]=pre[r]则我们可以知道区间[l,r]一定不合法 于是我们就要让不合法的区间尽量少 我们知道对于一个数$x$,他只受x和$(2^k-1)$ ...
- Entity Framework Tutorial Basics(5):Create Entity Data Model
Create Entity Data Model: Here, we are going to create an Entity Data Model (EDM) for SchoolDB datab ...
- Eclipse报错could not write metadata for '/remotesystemstempfiles'
1. windows-Preferences 中,在search中输入remote,取消选中reopen remote systems view to previous state'. 2. win ...
- JLink间接烧写【转自armobbs】
1. 简要说明 JLink的调试功能.烧写Flash的功能都很强大,但是对于S3C2410.S3C2440的Flash操作有些麻烦:烧写Nor Flash时需要设置SDRAM,否则速率很慢:烧写Nan ...
- 修改Oracle游标数及排查游标问题相关SQL
查看当前游标数show parameter open_cursors; 修改游标最大数 ; commit; 查看游标消费情况 select o.sid, osuser, machine, count( ...
- 数组最后一个元素的 引用在 foreach 循环之后仍会保留。建议使用 unset() 来将其销毁
数组最后一个元素$arr = array( 1 , 2 , 3 , 4 );foreach ( $arr as & $value ) { $value = $value ...
- Docker基本使用(二) Hello World
Docker 允许你在容器内运行应用程序, 使用 docker run 命令来在容器内运行一个应用程序. 输出Hello world runoob@runoob:~$ docker run ubunt ...