codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

676B.md (2319B)


      1 Source: https://codeforces.com/problemset/problem/676/B
      2 
      3 B. Pyramid of Glasses
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 Pictures below illustrate the pyramid consisting of three levels.
     28 
     29  ![](https://espresso.codeforces.com/e11e33889c15c83b858dd3070414d44509e98e0e.png) ![](https://espresso.codeforces.com/d3764d78b21cf5c21b9f8ce3109adfee4ca01c19.png)
     30 
     31 Input
     32 
     33 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.
     34 
     35 Output
     36 
     37 Print the single integer — the number of completely full glasses after *t* seconds.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3 5
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 4
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 4 8
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 6
     63 ```
     64 
     65 Note
     66 
     67 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.