CF 676B Pyramid of Glasses[模拟]
1 second
256 megabytes
standard input
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 nglasses.
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.


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.
Print the single integer — the number of completely full glasses after t seconds.
3 5
4
4 8
6
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.
把所有的先倒到第一个杯子里,然后如果>1就(x-1)/2分给下面的
//
// main.cpp
// cf676b
//
// Created by Candy on 9/14/16.
// Copyright © 2016 Candy. All rights reserved.
// #include <iostream>
#include <cstdio>
using namespace std;
const int N=;
int n,t,ans=;
double a[N][N];
int main(int argc, const char * argv[]) {
scanf("%d%d",&n,&t);
a[][]=t;
for(int i=;i<=n-;i++){
for(int j=;j<=i;j++){
if(a[i][j]<=) continue;
a[i+][j]+=(a[i][j]-)/;
a[i+][j+]+=(a[i][j]-)/;
}
}
for(int i=;i<=n;i++) for(int j=;j<=i;j++) if(a[i][j]>=) ans++;
printf("%d",ans);
return ;
}
CF 676B Pyramid of Glasses[模拟]的更多相关文章
- 【CF 676B Pyramid of Glasses】模拟,递归
题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求 ...
- codeforces 676B B. Pyramid of Glasses(模拟)
题目链接: B. Pyramid of Glasses time limit per test 1 second memory limit per test 256 megabytes input s ...
- 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 ...
- B. Pyramid of Glasses
原题链接 B. Pyramid of Glasses Mary has just graduated from one well-known University and is now attendi ...
- Pyramid of Glasses(递推)
Pyramid of Glasses time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforce#354_B_Pyramid of Glasses(模拟)
题目连接:http://codeforces.com/contest/676/problem/B 题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的 题解:由于数据不 ...
- CF 999B. Reversing Encryption【模拟/string reverse】
[链接]:CF [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F fir ...
- CF #366 DIV2 C. Thor 模拟 queue/stack降低复杂度
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- [Codeforces676B]Pyramid of Glasses(递推,DP)
题目链接:http://codeforces.com/problemset/problem/676/B 递推,dp(i, j)表示第i层第j个杯子,从第一层开始向下倒,和数塔一样的题.每个杯子1个时间 ...
随机推荐
- 【CSS3】css3:box-sizing属性
本文介绍了css3中的box-sizing属性,在这之前读者需要预备知识width的范围. 浏览器的支持情况 Browser Suppored Notes Internet Explorer Yes ...
- scroll事件实现监控滚动条并分页显示示例(zepto.js)
scroll事件实现监控滚动条并分页显示示例(zepto.js ) 需求:在APP落地页上的底部位置显示此前其他用户的购买记录,要求此div盒子只显示3条半,但一页有10条,div内的滑动条滑到一页 ...
- Spring(3)—— Junit框架单元测试
Junit主要用于单元测试,即白盒测试.它是一个开源的由JAVA开发的一个用于测试的框架. Junit的几个基本概念:TestCase,TestSuite,TestFixtrue TestCase:代 ...
- 30分钟手把手教你学webpack实战
30分钟手把手教你学webpack实战 阅读目录 一:什么是webpack? 他有什么优点? 二:如何安装和配置 三:理解webpack加载器 四:理解less-loader加载器的使用 五:理解ba ...
- SharePoint 2013 JavaScript API 记录
1.获取创建者字段(Author),oListItem为SPListItem对象 oListItem.get_item('Author')只能获取到对象,获取用户名要用oListItem.get_it ...
- Linux新手扫盲
一. Linux特点 1.免费/开源: 2.支持多线程/多用户: 3.安全性好: 4.对内存和文件管理优越. Linux最小只需4M ——> 嵌入式开发 二. 文件目录 Linux系统所有软硬件 ...
- Android之滑屏动画和自定义控件
滑屏动画 在Android系统中,通过手势识别切换界面时,通常会在界面切换时加入动画,以提高用户的体验效果,这种动画一般都采用平移动画,下一个界面进入时,上一个界面移除屏幕. 图中标识的均为左上角坐标 ...
- UI键盘通知
#import "ViewController.h" @interface ViewController () @property (nonatomic,strong) UITex ...
- Android 图片的合成
本文实现在Android下图片的合成 布局设计比较简单: <RelativeLayout xmlns:android="http://schemas.android.com/apk/r ...
- 【读书笔记】iOS-给模拟器相册增加图片
一,打开模拟器(如下图所示)----->找到模拟器中的相册---->打开相册---->把要添加的图片拖动到模拟器中.