题目链接:

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
  1. 3 5
output
  1. 4
input
  1. 4 8
output
  1. 6
  2.  
  3. 题意:
  4.  
  5. 像图中那样摆放杯子,共n层,问t分之后有多少杯子被倒满了;
  6.  
  7. 思路:
  8.  
  9. 模拟倒酒的过程,然后再统计就好了;
  10.  
  11. AC代码:
  1. #include <bits/stdc++.h>
  2. /*
  3. #include <iostream>
  4. #include <queue>
  5. #include <cmath>
  6. #include <map>
  7. #include <cstring>
  8. #include <algorithm>
  9. #include <cstdio>
  10. */
  11. using namespace std;
  12. #define Riep(n) for(int i=1;i<=n;i++)
  13. #define Riop(n) for(int i=0;i<n;i++)
  14. #define Rjep(n) for(int j=1;j<=n;j++)
  15. #define Rjop(n) for(int j=0;j<n;j++)
  16. #define mst(ss,b) memset(ss,b,sizeof(ss));
  17. typedef long long LL;
  18. const LL mod=1e9+;
  19. const double PI=acos(-1.0);
  20. const LL inf=1e18;
  21. const int N=1e6+;
  22. int n,t;
  23. double a[][];
  24. void fun()
  25. {
  26. a[][]+=;
  27. Riep(n)
  28. {
  29. Rjep(i)
  30. {
  31. if(a[i][j]>)
  32. {
  33. a[i+][j]+=(a[i][j]-)/;
  34. a[i+][j+]+=(a[i][j]-)/;
  35. a[i][j]=;
  36. }
  37. }
  38. }
  39. }
  40. int main()
  41. {
  42. scanf("%d%d",&n,&t);
  43. for(int i=;i<=t;i++)fun();
  44. int ans=;
  45. Riep(n)
  46. {
  47. Rjep(i)if(a[i][j]>=)ans++;
  48. }
  49. printf("%d\n",ans);
  50.  
  51. return ;
  52. }
  1.  

codeforces 676B B. Pyramid of Glasses(模拟)的更多相关文章

  1. Codeforces Round #354 (Div. 2) B. Pyramid of Glasses 模拟

    B. Pyramid of Glasses 题目连接: http://www.codeforces.com/contest/676/problem/B Description Mary has jus ...

  2. CF 676B Pyramid of Glasses[模拟]

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

  3. B. Pyramid of Glasses

    原题链接 B. Pyramid of Glasses Mary has just graduated from one well-known University and is now attendi ...

  4. Pyramid of Glasses(递推)

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

  5. 【CF 676B Pyramid of Glasses】模拟,递归

    题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求 ...

  6. codeforces 676B 模拟 递推

    题意:每秒从最高处的杯子倒一杯酒下来,酒流的方式如图,问t秒装满酒的杯子的数目. 思路:把第一杯的值设为t,glass[i][j]=(glass[i-1][j-1]-1)/2+(glass[i-1][ ...

  7. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  8. Codeforces Round #304 C(Div. 2)(模拟)

    题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...

  9. Codeforces 749C:Voting(暴力模拟)

    http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...

随机推荐

  1. C:进制

     进制.C语言内存分配 1.对于进制 10进制 (0 - 9)16进制 (0——9 A B C D E F)硬件中的高低电平(0 和 1表示)所以计算机用 二进制 机器语言就是由 0 和 1 组成的一 ...

  2. C#.Net中的非托管代码清理

    帮助其它项目组Review代码过程,发现有些地方实现了IDispose接口,同时也发现了一些关于IDispose的问题: 1.A类型实现了IDispose接口,B类型里面含有A类型的字段,B类型没有实 ...

  3. J2EE(java)后台调用ArcGIS Engine(AE)的部署和代码

    arcgis的BS开发解决方案一直是个坑,主推的地图服务查询速度慢,需要异步,功能少.相对来说主要用于CS的AE功能更强大全面,只是部署有点复杂 本文软件环境: win7 sp1 64位 MyEcli ...

  4. Codeforces Educational Codeforces Round 5 C. The Labyrinth 带权并查集

    C. The Labyrinth 题目连接: http://www.codeforces.com/contest/616/problem/C Description You are given a r ...

  5. discuz+ecmall+phpcms整合

    所需软件 discuzx1.5 (包含ucenter1.5) ecmall2.3 phpcms v9.5 1.先安装discuz1.5 2.然后安装ecmall2.3 3.最后安装phpcms v9. ...

  6. C++进制转换(十进制转二进制、八进制、随意进制)

    十进制转二进制: //十进制转二进制 #include<iostream> using namespace std; void printbinary(const unsigned int ...

  7. 深入理解 CSS 中的行高与基线

    1.基本概念 1.  基线.底线.顶线.中线 注意:基线(base line)并不是汉字文字的下端沿,而是英文字母“x”的下端沿. 2. 内容区 内容区是指底线和顶线包裹的区域(行内元素display ...

  8. Session丢失,都是CDN惹的祸

    周六下午,正在外面吃饭,运营的同事火急火燎地给我打电话,说是网站出问题了,用户登录不了,而且这种情况也不是全部,只有部分地区有问题.没办法,只能回到家里找问题,打开代码,翻来覆去地找问题,搞了整整一下 ...

  9. linux下的十六进制编辑器---wxHexEdit

    ....其实wxHexEdit是一个跨平台的十六进制编辑器,支持windows,linux,mac. 之所以标题用linux...是因为windows下多数都用winhex,UE之类的编辑器,而lin ...

  10. 数据挖掘算法-Apriori Algorithm(关联规则)

    http://www.cnblogs.com/jingwhale/p/4618351.html Apriori algorithm是关联规则里一项基本算法.是由Rakesh Agrawal和Ramak ...