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个时间 ...
随机推荐
- asp.net面试题汇总
1.静态成员和非静态成员的区别? 答: 静态变量使用 static 修饰符进行声明,在类被实例化时创建,通过类进行访问不带有 static 修饰符声明的变量称做非静态变量,在对象被实例化时创建,通过对 ...
- ABAP 加密解密程序
用于对字符串的加密和解密: DATA: o_encryptor TYPE REF TO cl_hard_wired_encryptor, o_cx_encrypt_error TYPE REF TO ...
- Java8 Lambda表达式教程
转自:http://blog.csdn.net/ioriogami/article/details/12782141 1. 什么是λ表达式 λ表达式本质上是一个匿名方法.让我们来看下面这个例子: pu ...
- 操作系统开发系列—12.e.Makefile
先来看一个简单的Makefile,我们把它放在目录/boot下,可以用来编译boot.bin和loader.bin. # Makefile for boot # Programs, flags, et ...
- iOS多线程解析
在这篇文章中,我将为你整理一下 iOS 开发中几种多线程方案,以及其使用方法和注意事项.当然也会给出几种多线程的案例,在实际使用中感受它们的区别.还有一点需要说明的是,这篇文章将会使用 Swift 和 ...
- Java核心:类加载和JVM内存的分配
类的加载: 指的是将class文件的二进制数据读入到运行时数据区(JVM在内存中划分的) 中,并在方法区内创建一个class对象. 类加载器: 负责加载编译后的class文件(字节码文件)到JVM(J ...
- 使用Android Annotations开发
使用Android Annotations框架gradle配置1.修改Module下的build.gradle apply plugin: 'com.android.application' appl ...
- android 界面设计基本知识Ⅱ
上一章讲述了Android界面设计时,一些基本控件的使用,本章主要讲述自定义控件,Fragment和Headler线程机制. 1.自定义控件 (1)基本知识 dp.sp和dx px:像素点 ...
- 回到过去美好的时光——源代码版本管理Always Use source code Control
Don't Repeat Yourself Don't Repeat Yourself,这是程序员修炼之道中的经典名言.源代码版本管理对程序员来说是非常重要的工作.因为它让你能够回到过去,而不用做重复 ...
- C#中==与Equals方法的区别
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace Console ...