[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时间,如果提前下课了,按 ...
随机推荐
- unity项目实现“再按一次退出程序”提示功能
unity项目,再按一次退出程序,按第一次做提示,再按一次,程序退出. float _waitTime = 2f;//前后两次按退出间隔时间 void OnGUI() { ) { GUI.Label( ...
- 使用ASP.NET注册工具aspnet_regiis.exe注册IIS
该工具的名称为aspnet_regiis.exe,在32位机上,该工具存在于C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727,在64位机中“Framework ...
- Interview-Largest independent set in binary tree.
BT(binary tree), want to find the LIS(largest independent set) of the BT. LIS: if the current node i ...
- 第一个Nodejs程序
我的第一个Nodejs程序:Hello World var http = require("http"); http.createServer(function(request, ...
- CentOS-6.5安装配置JDK-7和JDK-8
安装说明 系统环境:centos-6.5 软件:jdk-7-linux-x64.rpm , jdk-8u5-linux-i586.tar.gz 下载地址:http://www.oracle.com/ ...
- [原创] zabbix学习之旅七:如何远程操作被监控机器
虽然我们已经创建了一个报警系统,但在实际场景中,运维人员从得到报警到实际解决问题有一定的时差,若业务系统没有做高可用,那业务不得不中断,对于某些要求严格的企业级环境,这是不可容忍的,那有没有方法能让z ...
- 来吧,给你的Winform列表控件画个妆
前言 以前看别人的控件好看只有羡慕的份:以前觉得控件重绘是个很复杂的东西:以前知道MSDN很全面很专业却一直没有好好用起来: 作为初级程序猿,不能原地踏步,来吧,让我们一起把 TreeView 美化一 ...
- display:none和visibility: hidden二三事
display:none属性后,HTML元素(对象)的宽度.高度等各种属性值都将“丢失”;而使用visibility:hidden属性后,HTML元素(对象)仅仅是在视觉上看不见(完全透明),而它所占 ...
- $POST数组论证($GET || $COOKIE || $REQUEST 同理)
我觉得还是有多个$_POST 如果只有一个$_POST,那么,多个人[同时]提交的话就不好处理 或者一个$_POST 时间限制(如同时钟周期)处理(不可能,不然响应没这么快) 或者 一个$_POS ...
- cf 363D
贪心加二分 虽然比赛后才过 ........ /************************************************************************* &g ...