题目链接:http://codeforces.com/problemset/problem/676/B

递推,dp(i, j)表示第i层第j个杯子,从第一层开始向下倒,和数塔一样的题。每个杯子1个时间能倒满,从上开始向下倒时间为t,那每个杯子不满的时候对下面的贡献一定是0,所以当dp[i][j]>=1的时候,计数倒满的杯子并且将溢出的酒向下平分。

  1. /*
  2. ━━━━━┒ギリギリ♂ eye!
  3. ┓┏┓┏┓┃キリキリ♂ mind!
  4. ┛┗┛┗┛┃\○/
  5. ┓┏┓┏┓┃ /
  6. ┛┗┛┗┛┃ノ)
  7. ┓┏┓┏┓┃
  8. ┛┗┛┗┛┃
  9. ┓┏┓┏┓┃
  10. ┛┗┛┗┛┃
  11. ┓┏┓┏┓┃
  12. ┛┗┛┗┛┃
  13. ┓┏┓┏┓┃
  14. ┃┃┃┃┃┃
  15. ┻┻┻┻┻┻
  16. */
  17. #include <algorithm>
  18. #include <iostream>
  19. #include <iomanip>
  20. #include <cstring>
  21. #include <climits>
  22. #include <complex>
  23. #include <fstream>
  24. #include <cassert>
  25. #include <cstdio>
  26. #include <bitset>
  27. #include <vector>
  28. #include <deque>
  29. #include <queue>
  30. #include <stack>
  31. #include <ctime>
  32. #include <set>
  33. #include <map>
  34. #include <cmath>
  35. using namespace std;
  36. #define fr first
  37. #define sc second
  38. #define cl clear
  39. #define BUG puts("here!!!")
  40. #define W(a) while(a--)
  41. #define pb(a) push_back(a)
  42. #define Rint(a) scanf("%d", &a)
  43. #define Rll(a) scanf("%I64d", &a)
  44. #define Rs(a) scanf("%s", a)
  45. #define Cin(a) cin >> a
  46. #define FRead() freopen("in", "r", stdin)
  47. #define FWrite() freopen("out", "w", stdout)
  48. #define Rep(i, len) for(int i = 0; i < (len); i++)
  49. #define For(i, a, len) for(int i = (a); i < (len); i++)
  50. #define Cls(a) memset((a), 0, sizeof(a))
  51. #define Clr(a, x) memset((a), (x), sizeof(a))
  52. #define Fuint(a) memset((a), 0x7f7f, sizeof(a))
  53. #define lrt rt << 1
  54. #define rrt rt << 1 | 1
  55. #define pi 3.14159265359
  56. #define RT return
  57. #define lowbit(x) x & (-x)
  58. #define onenum(x) __builtin_popcount(x)
  59. typedef long long LL;
  60. typedef long double LD;
  61. typedef unsigned long long Uint;
  62. typedef pair<int, int> pii;
  63. typedef pair<string, int> psi;
  64. typedef map<string, int> msi;
  65. typedef vector<int> vi;
  66. typedef vector<int> vl;
  67. typedef vector<vl> vvl;
  68. typedef vector<bool> vb;
  69.  
  70. const int maxn = ;
  71. int n, t;
  72. double dp[maxn][maxn];
  73.  
  74. int main() {
  75. // FRead();
  76. Rint(n); Rint(t);
  77. int ret = ;
  78. dp[][] = t;
  79. For(i, , n+) {
  80. For(j, , i+) {
  81. if(dp[i][j] >= ) {
  82. dp[i][j] -= ;
  83. dp[i+][j] += (dp[i][j]) / ;
  84. dp[i+][j+] += (dp[i][j]) / ;
  85. ret++;
  86. }
  87. }
  88. }
  89. printf("%d\n", ret);
  90. RT ;
  91. }

[Codeforces676B]Pyramid of Glasses(递推,DP)的更多相关文章

  1. 递推DP URAL 1167 Bicolored Horses

    题目传送门 题意:k个马棚,n条马,黑马1, 白马0,每个马棚unhappy指数:黑马数*白马数,问最小的unhappy值是多少分析:dp[i][j] 表示第i个马棚放j只马的最小unhappy值,状 ...

  2. 递推DP URAL 1017 Staircases

    题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转 ...

  3. 递推DP URAL 1260 Nudnik Photographer

    题目传送门 /* 递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数 */ #include <cstdio> #include <algorithm> ...

  4. 递推DP URAL 1353 Milliard Vasya's Function

    题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k] ...

  5. 递推DP URAL 1119 Metro

    题目传送门 /* 题意:已知起点(1,1),终点(n,m):从一个点水平或垂直走到相邻的点距离+1,还有k个抄近道的对角线+sqrt (2.0): 递推DP:仿照JayYe,处理的很巧妙,学习:) 好 ...

  6. 递推DP 赛码 1005 Game

    题目传送门 /* 递推DP:官方题解 令Fi,j代表剩下i个人时,若BrotherK的位置是1,那么位置为j的人是否可能获胜 转移的时候可以枚举当前轮指定的数是什么,那么就可以计算出当前位置j的人在剩 ...

  7. 递推DP HDOJ 5328 Problem Killer

    题目传送门 /* 递推DP: 如果a, b, c是等差数列,且b, c, d是等差数列,那么a, b, c, d是等差数列,等比数列同理 判断ai-2, ai-1, ai是否是等差(比)数列,能在O( ...

  8. hdu1978(递推dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1978 分析: 递推DP. dp[][]表示可以到达改点的方法数. 刚开始:外循环扫描所有点dp[x][ ...

  9. 递推DP URAL 1031 Railway Tickets

    题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...

  10. 递推DP UVA 607 Scheduling Lectures

    题目传送门 题意:教授给学生上课,有n个主题,每个主题有ti时间,上课有两个限制:1. 每个主题只能在一节课内讲完,不能分开在多节课:2. 必须按主题顺序讲,不能打乱.一节课L时间,如果提前下课了,按 ...

随机推荐

  1. yiibooster+bsie

    对于使用yii框架来说,如果使用bootstrap框架的话,现在有一个比较方便的使用途径:yiibooster.官网地址是:http://yii-booster.clevertech.biz/当然,我 ...

  2. Android存储机制之Preference

    Preference提供了一种轻量级的数据存取方法,主要是数据比较少的配置信息.它以键值对的方式将数据保存在一个XML配置文件中. 使用Preference方式来存取数据,用到了SharedPrefe ...

  3. 【学习总结】iOS 数据保存几种方式总结

    在iOS开发过程中,不管是做什么应用,都会碰到数据保存的问题.将数据保存到本地,能够让程序的运行更加流畅,不会出现让人厌恶的菊花形状,使得用户体验更好.下面介绍一下数据保存的方式: NSKeyedAr ...

  4. Fibonacci数

    Fibonacci数 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递 ...

  5. asp.net 中插入数据到access

    这样报语法错误: insert into Menu_wx(userid,menutype,MenuID,menuname,MenuTitle,Url,Key,OrderValue,State) val ...

  6. 1996: [Hnoi2010]chorus 合唱队 - BZOJ

    Description Input Output Sample Input41701 1702 1703 1704Sample Output8HINT 水题,区间dp,f[l,r,k]表示区间[l,r ...

  7. IntelliJ IDEA 14 创建maven项目二

    前言: 在我的idea14使用maven创建web工程文章介绍了如何运用idea14创建maven项目--但有瑕疵,如下: 今天在群里交流才得知起因: 原来一直这样创建的--但结果都一样,均出现上面的 ...

  8. 本地不安装oracle-client,使用pl/sql developer连接数据库

    一.问题描述 本地未安装oracle-client端,由于机器资源有限,希望通过pl/sql developer进行远程数据库连接.单纯的安装pl/sql developer无法远程连接数据库. 二. ...

  9. [nowCoder] 完全二叉树结点数

    给定一棵完全二叉树的头节点head,返回这棵树的节点个数.如果完全二叉树的节点数为N,请实现时间复杂度低于O(N)的解法. 分析:遍历的话不管是前序.中序.后序还是层次都是O(N),低于O(N)只能是 ...

  10. PHP对XML文件操作类讲解

    <?phpclass XML{    private $dom;        function __construct ()    {        $this->dom = new D ...