zoukankan      html  css  js  c++  java
  • Codeforces Round #354 (Div. 2) B

    B. Pyramid of Glasses
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is n. The top level consists of only 1 glass, that stands on 2 glasses on the second level (counting from the top), then 3 glasses on the third level and so on.The bottom level consists of n glasses.

    Vlad has seen in the movies many times how the champagne beautifully flows from top levels to bottom ones, filling all the glasses simultaneously. So he took a bottle and started to pour it in the glass located at the top of the pyramid.

    Each second, Vlad pours to the top glass the amount of champagne equal to the size of exactly one glass. If the glass is already full, but there is some champagne flowing in it, then it pours over the edge of the glass and is equally distributed over two glasses standing under. If the overflowed glass is at the bottom level, then the champagne pours on the table. For the purpose of this problem we consider that champagne is distributed among pyramid glasses immediately. Vlad is interested in the number of completely full glasses if he stops pouring champagne in t seconds.

    Pictures below illustrate the pyramid consisting of three levels.

    Input

    The only line of the input contains two integers n and t (1 ≤ n ≤ 10, 0 ≤ t ≤ 10 000) — the height of the pyramid and the number of seconds Vlad will be pouring champagne from the bottle.

    Output

    Print the single integer — the number of completely full glasses after t seconds.

    Examples
    Input
    3 5
    Output
    4
    Input
    4 8
    Output
    6
    Note

    In the first sample, the glasses full after 5 seconds are: the top glass, both glasses on the second level and the middle glass at the bottom level. Left and right glasses of the bottom level will be half-empty.

    题意:n层杯子 每秒只能倒满一个杯子 然后液体向下流 如图   问t秒后能倒满几个杯子

    题解:想那么多干嘛 暴力处理 暴力每秒液体的去向 并累计  然后判断n层杯子能满几杯

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<cmath>
     5 #include<queue>
     6 #include<stack>
     7 #include<map>
     8 #define ll __int64
     9 #define pi acos(-1.0) 
    10 using namespace std;
    11 double a[15][15];
    12 int n,t;
    13 int main()
    14 {
    15     scanf("%d %d",&n,&t);
    16     for(int i=1;i<=10;i++)
    17     {
    18         for(int j=1;j<=i;j++)
    19          a[i][j]=0;
    20     }
    21     while(t)
    22     {
    23         a[1][1]+=1;
    24         for(int i=1;i<=10;i++)
    25         {
    26             for(int j=1;j<=i;j++)
    27             {
    28                  if(a[i][j]>1)
    29                  {
    30                      a[i+1][j]+=(a[i][j]-1)/2.0;
    31                      a[i+1][j+1]+=(a[i][j]-1)/2.0;
    32                      a[i][j]=1;
    33                  }
    34             }
    35         }
    36         t--;
    37     }
    38     int ans=0;
    39     for(int i=1;i<=n;i++)
    40     {
    41         for(int j=1;j<=i;j++)
    42         {
    43             if(abs(a[i][j]-1)<0.000001)
    44             ans++;
    45         }
    46     }
    47     cout<<ans<<endl;
    48     return 0;
    49 }
  • 相关阅读:
    windows下GitHub的SSH Key 配置
    bootdo开源项目修改代码后页面无效
    携程第二场预赛 1003:位图像素的颜色(水题,判断点是否在矩形内)
    hdu 2105:The Center of Gravity(计算几何,求三角形重心)
    《随机出题软件》&《随机分队软件》源码(Windows API)
    hdu 1426:Sudoku Killer(DFS深搜,进阶题目,求数独的解)
    fzu 1330:Center of Gravity(计算几何,求扇形重心)
    hrbustoj 1104:Leyni, LOLI and Line(解析几何,斜截式的应用)
    poj 3348:Cows(计算几何,求凸包面积)
    《linux系统及其编程》实验课记录(五)
  • 原文地址:https://www.cnblogs.com/hsd-/p/5536269.html
Copyright © 2011-2022 走看看