HDU1398:Square Coins(DP水题)
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15764 Accepted Submission(s): 10843
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
4
27

#define _CRT_SECURE_NO_DepRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cctype>
#include <iterator>
#include <vector>
#include <cstring>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define ll long long
#define INF 0x3f3f3f3f
#define ld long double
const ld pi = acos(-.0L), eps = 1e-;
int qx[] = { ,,,- }, qy[] = { ,-,, }, qxx[] = { ,- }, qyy[] = { ,- };
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n, num[], dp[] = { };
for (int i = ; i <= ; i++)//先打表
{
num[i] = i * i;
}
dp[] = ;
for (int i = ; i <= ; i++)//依次计算17种面值的货币的情况
{
for (int f = ; f <= ; f++)
{
if (f - num[i] < )
{
continue;
}
dp[f] += dp[f - num[i]];//意即f-num[i]的情况下再加一张num[i]即为f
}
}
while (cin >> n && n)
{
cout << dp[n] << endl;
}
return ;
}
HDU1398:Square Coins(DP水题)的更多相关文章
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题
除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...
- HDU 1398 Square Coins(DP)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- 13年山东省赛 The number of steps(概率dp水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud The number of steps Time Limit: 1 Sec Me ...
- HDU1398 Square Coins(生成函数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- HDU1398 Square Coins
Description People in Silverland use square coins. Not only they have square shapes but also their v ...
- dp水题 序列问题 (9道)
9道题.A了8道,A题看题解也没弄懂怎么维护m段子序列的,过一段时间再回来看看 dp试水 47:56:23 125:00:00 Overview Problem Status Rank ( ...
- 【BZOJ】1270: [BeijingWc2008]雷涛的小猫(DP+水题)
http://www.lydsy.com/JudgeOnline/problem.php?id=1270 这完全是一眼题啊,但是n^2的时间挺感人.(n^2一下的级别请大神们赐教,我还没学多少dp优化 ...
随机推荐
- Java集合03——你不得不了解的Map
Map 在面试中永远是一个绕不开的点,本文将详细讲解Map的相关内容.关注公众号「Java面典」了解更多 Java 知识点. Map Map 是一个键值对(key-value)映射接口: 映射中不能包 ...
- 数据结构 - Collection接口
简介 Collection继承自Iterable,Collection接口是Java集合两大分支中的一支,Queue.List.Set都是Collection的扩展:集合大类分为了Collection ...
- jQuery实现鼠标移入切换图片
初始效果: 鼠标移入效果: 首先添加jQuery库,我这边直接引用百度CDN地址 <script src="https://apps.bdimg.com/libs/jquery/2.1 ...
- .NET Conf: Xamarin专场会议3.23 开幕
聚焦于 Xamarin 的 NET Conf 是一项免费的为期一天的直播活动,来自社区和.NET产品团队的演讲者正在使用Xamarin技术构建本机移动应用程序!Xamarin允许您使用C#(而不是Ja ...
- 题解 NOIP2018【赛道修建】—— 洛谷
这道题有一点点树上dp的意思(大佬轻喷 我刚拿到这道题的时候毫无头绪,只知道这道题要二分答案 为什么是二分答案??? 题目: 目前赛道修建的方案尚未确定.你的任务是设计一 种赛道修建的方案,使得修建的 ...
- 《Linux环境进程间通信》系列文章链接
深刻理解 Linux 进程间通信(IPC) http://www.ibm.com/developerworks/cn/linux/l-ipc/index.html Linux 环境进程间通信(一): ...
- 计算属性(computed)+侦听器(watch)+ 方法(methods)
计算属性 computed 当数据改变时,方法的结果也会发生改变.如果多处地方调用计算属性里面的同一个方法时,该方法只会执行一次.如图,在控制台改变data里面的num值时,虽然在多处使用comput ...
- iview mock main.js
main.js // 实际打包时应该不引入mock /* eslint-disable */ // if (process.env.NODE_ENV !== 'production') require ...
- nlogn的最长不下降子序列【tyvj1254挑选士兵】
var a,d:Array[-..]of longint; i,n,m,k,l:longint; function erfen(x:longint):longint; var mid,h,t:long ...
- css定位属性的运用
position 定位定位:主要解决叠加排列的问题.position 1.static(默认) 2.relative : 相对定位 如果没有定位偏移量,对元素本身没有任何影响(一般用于需要加定位的父容 ...