• 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 }
  • 相关阅读:
    char array 与string
    汗= =
    看来要学 Asp.Net 了
    安装 Xamarin for Visual Studio
    Xamarin for Visual Studio 3.11.658 Alpha 版 破解补丁
    用 Xamarin for VS 创建 aar 文件的绑定
    Android中当前墙纸Wallpaper存放的位置
    Android中动态改变控件的大小的一种方法
    程序员学习能力提升三要素(读书笔记)
    让Android软键盘默认进入英文键盘
  • 原文地址:https://www.cnblogs.com/hsd-/p/5536269.html
Copyright © 2020-2023  润新知