[Codeforces676B]Pyramid of Glasses(递推,DP)

时间:2023-03-09 04:59:12
[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 ;
}