[Codeforces676B]Pyramid of Glasses(递推,DP)
题目链接:http://codeforces.com/problemset/problem/676/B
递推,dp(i, j)表示第i层第j个杯子,从第一层开始向下倒,和数塔一样的题。每个杯子1个时间能倒满,从上开始向下倒时间为t,那每个杯子不满的时候对下面的贡献一定是0,所以当dp[i][j]>=1的时候,计数倒满的杯子并且将溢出的酒向下平分。
- /*
- ━━━━━┒ギリギリ♂ eye!
- ┓┏┓┏┓┃キリキリ♂ mind!
- ┛┗┛┗┛┃\○/
- ┓┏┓┏┓┃ /
- ┛┗┛┗┛┃ノ)
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┃┃┃┃┃┃
- ┻┻┻┻┻┻
- */
- #include <algorithm>
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- #include <climits>
- #include <complex>
- #include <fstream>
- #include <cassert>
- #include <cstdio>
- #include <bitset>
- #include <vector>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <ctime>
- #include <set>
- #include <map>
- #include <cmath>
- using namespace std;
- #define fr first
- #define sc second
- #define cl clear
- #define BUG puts("here!!!")
- #define W(a) while(a--)
- #define pb(a) push_back(a)
- #define Rint(a) scanf("%d", &a)
- #define Rll(a) scanf("%I64d", &a)
- #define Rs(a) scanf("%s", a)
- #define Cin(a) cin >> a
- #define FRead() freopen("in", "r", stdin)
- #define FWrite() freopen("out", "w", stdout)
- #define Rep(i, len) for(int i = 0; i < (len); i++)
- #define For(i, a, len) for(int i = (a); i < (len); i++)
- #define Cls(a) memset((a), 0, sizeof(a))
- #define Clr(a, x) memset((a), (x), sizeof(a))
- #define Fuint(a) memset((a), 0x7f7f, sizeof(a))
- #define lrt rt << 1
- #define rrt rt << 1 | 1
- #define pi 3.14159265359
- #define RT return
- #define lowbit(x) x & (-x)
- #define onenum(x) __builtin_popcount(x)
- typedef long long LL;
- typedef long double LD;
- typedef unsigned long long Uint;
- typedef pair<int, int> pii;
- typedef pair<string, int> psi;
- typedef map<string, int> msi;
- typedef vector<int> vi;
- typedef vector<int> vl;
- typedef vector<vl> vvl;
- typedef vector<bool> vb;
- const int maxn = ;
- int n, t;
- double dp[maxn][maxn];
- int main() {
- // FRead();
- Rint(n); Rint(t);
- int ret = ;
- dp[][] = t;
- For(i, , n+) {
- For(j, , i+) {
- if(dp[i][j] >= ) {
- dp[i][j] -= ;
- dp[i+][j] += (dp[i][j]) / ;
- dp[i+][j+] += (dp[i][j]) / ;
- ret++;
- }
- }
- }
- printf("%d\n", ret);
- RT ;
- }
[Codeforces676B]Pyramid of Glasses(递推,DP)的更多相关文章
- 递推DP URAL 1167 Bicolored Horses
题目传送门 题意:k个马棚,n条马,黑马1, 白马0,每个马棚unhappy指数:黑马数*白马数,问最小的unhappy值是多少分析:dp[i][j] 表示第i个马棚放j只马的最小unhappy值,状 ...
- 递推DP URAL 1017 Staircases
题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转 ...
- 递推DP URAL 1260 Nudnik Photographer
题目传送门 /* 递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数 */ #include <cstdio> #include <algorithm> ...
- 递推DP URAL 1353 Milliard Vasya's Function
题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k] ...
- 递推DP URAL 1119 Metro
题目传送门 /* 题意:已知起点(1,1),终点(n,m):从一个点水平或垂直走到相邻的点距离+1,还有k个抄近道的对角线+sqrt (2.0): 递推DP:仿照JayYe,处理的很巧妙,学习:) 好 ...
- 递推DP 赛码 1005 Game
题目传送门 /* 递推DP:官方题解 令Fi,j代表剩下i个人时,若BrotherK的位置是1,那么位置为j的人是否可能获胜 转移的时候可以枚举当前轮指定的数是什么,那么就可以计算出当前位置j的人在剩 ...
- 递推DP HDOJ 5328 Problem Killer
题目传送门 /* 递推DP: 如果a, b, c是等差数列,且b, c, d是等差数列,那么a, b, c, d是等差数列,等比数列同理 判断ai-2, ai-1, ai是否是等差(比)数列,能在O( ...
- hdu1978(递推dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1978 分析: 递推DP. dp[][]表示可以到达改点的方法数. 刚开始:外循环扫描所有点dp[x][ ...
- 递推DP URAL 1031 Railway Tickets
题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...
- 递推DP UVA 607 Scheduling Lectures
题目传送门 题意:教授给学生上课,有n个主题,每个主题有ti时间,上课有两个限制:1. 每个主题只能在一节课内讲完,不能分开在多节课:2. 必须按主题顺序讲,不能打乱.一节课L时间,如果提前下课了,按 ...
随机推荐
- yiibooster+bsie
对于使用yii框架来说,如果使用bootstrap框架的话,现在有一个比较方便的使用途径:yiibooster.官网地址是:http://yii-booster.clevertech.biz/当然,我 ...
- Android存储机制之Preference
Preference提供了一种轻量级的数据存取方法,主要是数据比较少的配置信息.它以键值对的方式将数据保存在一个XML配置文件中. 使用Preference方式来存取数据,用到了SharedPrefe ...
- 【学习总结】iOS 数据保存几种方式总结
在iOS开发过程中,不管是做什么应用,都会碰到数据保存的问题.将数据保存到本地,能够让程序的运行更加流畅,不会出现让人厌恶的菊花形状,使得用户体验更好.下面介绍一下数据保存的方式: NSKeyedAr ...
- Fibonacci数
Fibonacci数 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递 ...
- asp.net 中插入数据到access
这样报语法错误: insert into Menu_wx(userid,menutype,MenuID,menuname,MenuTitle,Url,Key,OrderValue,State) val ...
- 1996: [Hnoi2010]chorus 合唱队 - BZOJ
Description Input Output Sample Input41701 1702 1703 1704Sample Output8HINT 水题,区间dp,f[l,r,k]表示区间[l,r ...
- IntelliJ IDEA 14 创建maven项目二
前言: 在我的idea14使用maven创建web工程文章介绍了如何运用idea14创建maven项目--但有瑕疵,如下: 今天在群里交流才得知起因: 原来一直这样创建的--但结果都一样,均出现上面的 ...
- 本地不安装oracle-client,使用pl/sql developer连接数据库
一.问题描述 本地未安装oracle-client端,由于机器资源有限,希望通过pl/sql developer进行远程数据库连接.单纯的安装pl/sql developer无法远程连接数据库. 二. ...
- [nowCoder] 完全二叉树结点数
给定一棵完全二叉树的头节点head,返回这棵树的节点个数.如果完全二叉树的节点数为N,请实现时间复杂度低于O(N)的解法. 分析:遍历的话不管是前序.中序.后序还是层次都是O(N),低于O(N)只能是 ...
- PHP对XML文件操作类讲解
<?phpclass XML{ private $dom; function __construct () { $this->dom = new D ...