码迷,mamicode.com
首页 > 其他好文 > 详细

[CF-676B]PYRAMID OF GLASSES

时间:2017-06-07 15:46:54      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:流量   ref   str   color   logs   name   target   namespace   amp   

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

很水的递推;

题目大意:

有一个n层的酒杯金字塔,每个酒杯容量为1。每秒钟,会有1份酒倒到最上方的酒杯里。当某个酒杯装满时,它会以同样的流量溢出到下一层的两个酒杯之中。求t秒过后有多少装满的酒杯。

可以假设第一层有容积为T的酒,对于每一个酒杯来说来说,如果now>=1,下一层的左右两边就分别 += (now-1)/2;

上代码

 1 #include<cstdio>
 2 #include<algorithm>
 3 #include<cmath>
 4 #include<iostream>
 5 #include<cstdlib>
 6 #include<string>
 7 #include<cstring>
 8 #include<queue>
 9 #include<deque>
10 #include<stack>
11 #define LL long long
12 using namespace std;
13 int n,t,ans;
14 double dp[15][15];
15 int main(){
16     scanf("%d%d",&n,&t);
17     dp[1][1] = t;
18     for(int i = 1;i <= n;i++)
19        for(int j = 1;j <= i;j++){
20              if(dp[i][j] >= 1.0){
21                   ans++;
22                   dp[i+1][j] += (dp[i][j]-1)/2;
23                   dp[i+1][j+1] += (dp[i][j]-1)/2;
24              }
25        }
26     printf("%d\n",ans);
27     return 0;
28 }

 

[CF-676B]PYRAMID OF GLASSES

标签:流量   ref   str   color   logs   name   target   namespace   amp   

原文地址:http://www.cnblogs.com/syx-799/p/6957078.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!