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个时间 ...
随机推荐
- 原生JS:Number对象详解
Number对象 本文参考MDN做的详细整理,方便大家参考MDN JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象.Number 对象由 Number() 构造器创建. ...
- HtmlAgilityPack---Html解析框架
如果你想从一段HTML中提取出指定的标记(如:获取所有的div.获取具有指定属性的元素)如果你想编辑一段HTML,修改里面的部分元素如果你想判断一段HTML中指定元素的关系(子节点.父节点.兄弟节点. ...
- tmtTable设计说明文档
文件链接:tmt-table.js BOSS后台项目用到最多的就是列表页,所以把列表页做成通用组件,可以大大提高开发效率. 因为列表可能有不同的样式,所以在实例化组件时可以传值控制样式,用这种方式: ...
- JavaSript模块规范 - AMD规范与CMD规范介绍 (转载lovenyf.blog.chinaunix.net)
JavaSript模块化 在了解AMD,CMD规范前,还是需要先来简单地了解下什么是模块化,模块化开发? 模块化是指在解决某一个复杂问题或者一系列的杂糅问题时,依照一种分类的思维把问题 ...
- READ TABLE ..... BINARY SEARCH问题
Read Table 的语法很多,这里说一种特殊情况,Read Table 中查询的时候对标准内表经常有一种二分优化查找,用Binary search的时候首先必须要有查询条件:但如果查询条件满足的项 ...
- 使用cocoaPods一键集成第三方登录(新浪微博,qq,微信)
第三方登录是现在app很常用的功能,而这个功能我已经写过两三次了...每次都写大同小异的代码真的是很痛苦,而且每次都要根据说明去添加那些依赖库,配置linkFlag什么的,完全是体力活,所以一直想把这 ...
- html 常用的标签
1.html 的基本格式 <html> <head> <meta charset="UTF-8"> <title>HTML5的标题& ...
- XMPP框架的分析、导入及问题解决
上一篇讲了 XMPP调试与简单使用 ,本篇开始讲如何使用将XMPPFramework框架导入到项目中! 先来了解以下XMPPFramework都放了些什么: Authentication: 与登陆相关 ...
- 学习 OAuth2.0
基于浏览器 访问后跳到登录页面,登录成功后跳转到授权页面,授权成功后跳转到redirect_uri指定的地址. 1.请求授权. http://localhost:8080/oauth/authoriz ...
- 测试必备技能系列4:如何用SSH向linux服务器上传下载文件
通过ssh方式,向远程服务器上传文件 非常方便 直接看老徐之前的文章http://www.51testing.com/?uid-497177-action-viewspace-itemid-37054 ...