CF 354 div2 B 酒杯金字塔
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 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.
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.
题意:摆了一个高脚杯金字塔,每秒钟往最上面倒一整杯,一杯满了会往两边溢出流到下面两个杯子,求n层高的金字塔,倒水k分钟后,有多少杯是满的。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-;
const int inf =0x7f7f7f7f;
const double pi=acos(-);
const int maxn=+; double a[][];
int main()
{
int n,t;
while(~scanf("%d %d",&n,&t))
{
int ans=;
MM(a,);
a[][]=t;
for(int i=;i<=n;i++)
for(int j=;j<=i;j++)
if(a[i][j]>=)
{
ans++;//a[i][j]第i行的第j个酒杯
a[i+][j]+=(a[i][j]-)/2.0;
a[i+][j+]+=(a[i][j]-)/2.0;
}
printf("%d\n",ans);
}
return ;
}
分析:一开始觉得这是道找规律的题,,然后就go die了,,其实只要先给第一个酒杯倒上所有的酒,然后从上往下模拟就好
上往下模拟就好
CF 354 div2 B 酒杯金字塔的更多相关文章
- cf 442 div2 F. Ann and Books(莫队算法)
cf 442 div2 F. Ann and Books(莫队算法) 题意: \(给出n和k,和a_i,sum_i表示前i个数的和,有q个查询[l,r]\) 每次查询区间\([l,r]内有多少对(i, ...
- CF#603 Div2
差不多半年没打cf,还是一样的菜:不过也没什么,当时是激情,现在已是兴趣了,开心就好. A Sweet Problem 思维,公式推一下过了 B PIN Codes 队友字符串取余过了,结果今天早上一 ...
- CF R631 div2 1330 E Drazil Likes Heap
LINK:Drazil Likes Heap 那天打CF的时候 开场A读不懂题 B码了30min才过(当时我怀疑B我写的过于繁琐了. C比B简单多了 随便yy了一个构造发现是对的.D也超级简单 dp了 ...
- CF#581 (div2)题解
CF#581 题解 A BowWow and the Timetable 如果不是4幂次方直接看位数除以二向上取整,否则再减一 #include<iostream> #include< ...
- [CF#286 Div2 D]Mr. Kitayuta's Technology(结论题)
题目:http://codeforces.com/contest/505/problem/D 题目大意:就是给你一个n个点的图,然后你要在图中加入尽量少的有向边,满足所有要求(x,y),即从x可以走到 ...
- CF 197 DIV2 Xenia and Bit Operations 线段树
线段树!!1A 代码如下: #include<iostream> #include<cstdio> #define lson i<<1 #define rson i ...
- codeforces 354 DIV2
B - Pyramid of Glasses n层杯子,问k分钟能流满多少个杯子?和到香槟一样的过程? 思路:应为水的流速为每分钟一立方体(YY),可以做个转化,把最上层的杯子最原始的容积看成K,每个 ...
- CF#345 div2 A\B\C题
A题: 贪心水题,注意1,1这组数据,坑了不少人 #include <iostream> #include <cstring> using namespace std; int ...
- CF R303 div2 C. Woodcutters
C. Woodcutters time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- GrapeCity Documents for Excel 文档API组件 V2.2 新特性介绍
GrapeCity Documents for Excel 文档API组件 V2.2 正式发布,本次新版本包含诸多重量级产品功能,如:将带有形状的电子表格导出为 PDF.控制分页和电子表格内容.将Ex ...
- nginx反向代理_负载均衡
注意ip地址为: 虚拟机ip设置 TYPE="Ethernet"BOOTPROTO="static"NAME="enp0s3"DEVICE= ...
- 谷歌官方颜色库 MaterialDesignColor
谷歌官方颜色库 MaterialDesignColor
- 错误:编码GBK的不可映射字符解决办法
今天在cmd测试java代码的时候遇到了一个错误 解决办法: 输入javac -encoding utf-8 文件名.java 原因: 由于JDK是国际版的,我们在用javac编译时,编译程序首 ...
- jQuery可拖拽旋转的3D图片墙
在线演示 本地下载
- Codeforces 1178B. WOW Factor
传送门 显然对每个 $o$ ,考虑左边和右边分别有多少 $w$,那么这个 $o$ 的贡献就是左右 $w$ 的出现次数相乘 $w$ 的出现次数可以直接根据每一段连续的 $v$ 得到 那么从左到右扫一遍, ...
- Collection接口的子接口——Set接口
https://docs.oracle.com/javase/8/docs/api/java/util/Set.html public interface Set<E> extends ...
- SQL----Group By and Having
合计函数 (比如 SUM) 常常需要添加 GROUP BY 语句. GROUP BY 语句 GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 语法 ...
- python:set() 函数
描述 Python 内置函数 创建一个无序不重复元素集 可进行关系测试,删除重复数据 集合对象还支持union(联合), intersection(交), difference(差)和sysmmetr ...
- Stream 分布式数据流的轻量级异步快照
1. 概述 分布式有状态流处理支持在云中部署和执行大规模连续计算,主要针对低延迟和高吞吐量.这种模式的一个最根本的挑战就是在可能的失败情况下提供处理保证.现有方法依赖于可用于故障恢复的周期性全局状态快 ...