题目链接:

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

题意:

像图中那样摆放杯子,共n层,问t分之后有多少杯子被倒满了;

思路:

模拟倒酒的过程,然后再统计就好了;

AC代码:
#include <bits/stdc++.h>
/*
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
*/
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e6+;
int n,t;
double a[][];
void fun()
{
a[][]+=;
Riep(n)
{
Rjep(i)
{
if(a[i][j]>)
{
a[i+][j]+=(a[i][j]-)/;
a[i+][j+]+=(a[i][j]-)/;
a[i][j]=;
}
}
}
}
int main()
{
scanf("%d%d",&n,&t);
for(int i=;i<=t;i++)fun();
int ans=;
Riep(n)
{
Rjep(i)if(a[i][j]>=)ans++;
}
printf("%d\n",ans); return ;
}

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. js 数组去重 的5种方法

    一万数组,4个重复项,先贴上成绩. 1.3毫秒 2.115毫秒 3.71毫秒 4.6毫秒 1.哈希表 2.JQuery (最快的方法是用JQuery 这句话是截图带的... 实际上Jq是最慢的) 3. ...

  2. Delphi thread exception mechanism

    http://www.techques.com/question/1-3627743/Delphi-thread-exception-mechanism i have a dilema on how ...

  3. Javascript如何访问和处理系统文件

    一.功能实现核心:FileSystemObject 对象 要在javascript中实现文件操作功能,主要就是依靠FileSystemobject对象. 二.FileSystemObject编程 使用 ...

  4. 12个非常不错的免费HTML后台管理模板

    下面介绍的这些免费后端管理HTML模板,都非常不错.建议您收藏. 1.  Charisma Admin Template (示例) Charisma是一个响应式管理模板,基于Twitter Boots ...

  5. Android Studio系列教程一--下载与安装

    背景 相信大家对Android Studio已经不陌生了,Android Studio是Google于2013 I/O大会针对Android开发推出的新的开发工具,目前很多开源项目都已经在采用,Goo ...

  6. Center OS jdk tomcat安装

    一.jdk安装 1.下载jdk    jdk-6u26-linux-i586-rpm.bin    2  安装jdk    #sh jdk-6u26-linux-i586-rpm.bin 3.#set ...

  7. java中十进制转二进制转换函数

    十进制转成十六进制: Integer.toHexString(int i) 十进制转成八进制 Integer.toOctalString(int i) 十进制转成二进制 Integer.toBinar ...

  8. XMPP协议、IM、客户端互联详解

    导读 对于推送,IM服务器,目前可以使用一些厂家提供的SDK来实现,但是我们的老板又总是担心使用别人的SDK,假如别人的服务出现问题,或者别人偷看咱们的信息,那岂不是出现很大问题了 聊一聊xmpp的服 ...

  9. 安装apache2.4.10

    一:依赖安装:apache依赖于apr,apr-util,pcre,所以需要先安装他,并且需要最新的 apr官网:http://apr.apache.org/download.cgi pcre官网:h ...

  10. [Tips]解决HG之waiting for lock on repository

    # Symptom 在tortoiseHg中commit或者Sync change的时候,总是出现下面的错误: waiting for lock on repository ... # Solutio ...