codeforces 676B Pyramid of Glasses 递归

安全运营面试总结 答案可以在我的博客中查找 1.自我介绍 2.TCP/IP七层模式 3.端口号(常见协议 数据库) 4.Owasp top 10 5.渗透测试过程 6.漏扫工具 7.中间件漏洞 8.应急响应 9.项目 10.SQL注入类型 11.TCP 三次握手 四次挥手 12.你有什么要问我的 1.自我介绍 2.项目介绍 3.宽字节注入的原理 4.渗透流程 5.... 阅读详情

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
Note

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.



#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int maxn = 15, lim = 1024;
int has[maxn][maxn], n;

//在(r, c)中填充剩下的lft的体积的酒
void fill(int r, int c, int lft) {
	if (r > n) return ;
	has[r][c] += lft; //将酒倒入

	//如果这个酒杯的酒满了,那么酒会往下流has[r][c] - lim这么多
	if (has[r][c] > lim) {
		int left = has[r][c] - lim;
		has[r][c] = lim; //流下去以后这个杯子保持满的状态
		fill(r + 1, c, left / 2);
		fill(r + 1, c + 1, left / 2);
	}
}

int main()
{
	int t;
	cin >> n >> t;
	memset(has, 0, sizeof(has));
	while(t--) {
		fill(1, 1, lim);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			ans += has[i][j] == lim;
		}
	}
	cout << ans << endl;
	return 0;
}




Unity-RetargetPro3-动画插件试用 一个名气大于实战的插件。 阅读详情

相关推荐

Unity 升级引擎版本后构建报错:script class layout is incompatible between the editor and the player

Unity升级引擎版本后,项目报错:script class layout is incompatible between the editor and the player。

学习与分享 607

CodeForces - 878D 递归(搜索)

开始有k个生物,有n个属性 支持3种操作: 1.将两个生物合并成一个新的生物,所有属性值为原来的较大值 2.将两个生物合并成一个新的生物,所有属性值为原来的较小值 3.询问i生物的第j个属性值 n<=1e5 k<=12 q<=1e5 Input 三个数 n k q分别表示属性数,生物数以及操作数 之后k行每行n个正整数,表示生物属性(属于[1,1e9]) 之后q行,每行3个...

weixin_44705665的博客 382

大白话MySQL执行SQL的流程

Server如果在查询缓存中发现了这条SQL语句,就会直接将结果返回给客户端;如果没有,如果进入到解析器阶段。需要说明的是,因为查询混窜往往效率不高,所以在MySQL8.0之后就抛弃了这个功能如上图所示一个sql执行的流程大致如下半双工协议缓存解析器预处理器查询优化器预处理器查询引擎存储引擎。

IT小郭的技术博客 974

B-Code For 1 Codeforces 768【递归】 好题!

题意:起初,序列中仅有数n,if(n!=0 && n!=1) 在原来的位置补充3个元素n/2 n/%2 n/2 。 直至该序列用仅有0和1。现在问区间[l,r]有多少个1思路:一开始想用vector模拟,感觉实现起来很麻烦,很繁琐。 去网上看了题解,首先要求出对于当前的n,一共能拆分成多少个元素(仅为0和1),那么区间长度就是[1,len]确定下来。接着去枚举每一个位置的值是0还是1(递归)。

Haipai1998的博客 630

C语言编写Picard迭代和牛顿迭代法

为了完成学校计算方法的作业,花了两个多星期将所有实验报告编写出来,看到同桌找代码的辛苦,CSDN也没有这类代码,我只是一时兴起,想分享我写的代码与大家共飨,有错误还请多多指正,代码都不难,也是为了让CSDN帮我保存下,我辛辛苦苦做出来的,倘若能给别人带来一丝一毫的帮助,我都万分荣幸。 1:什么是Picard迭代 先弄一个满足f(x) = 0的函数将其转化为x= 正在上传… 重新上传 取消 ...

mohenxiang的博客 4716

Axure RP9汉化+授权全攻略:从下载到激活一步到位(附最新授权码)

本文提供Axure RP9从下载安装到界面汉化的完整指南,帮助设计师和产品经理快速上手这款原型设计工具。详细讲解了如何安全获取软件、执行汉化操作、理解核心界面布局,并介绍了创建交互原型和生成HTML文件的基础步骤,助力用户高效开展设计工作。

cuda7parallel的博客 1166

Codeforces 768B Code For 1 【递归】

传送门:Codeforces 768B 题意: 给你一个数n,如果n!=0&&n!=1,就将他换成n/2,n%2,n/2三个数,然后一直对这个序列里的数(>1)进行这个操作,知道这个序列只剩0和1。 给你一个范围[l,r][l,r][l,r],问你这个范围里有几个1。 题解: 对于给出的数n,我们是可以判断最后这个序列的长度len的(每次len*2+1),然后在 [...

Waiting For You 802

Coze智能体网页集成实战:从零搭建免登录AI助手

本文详细介绍了如何利用Coze Chat SDK从零开始为网站集成免登录AI助手。通过获取访问令牌和智能体ID,仅需几行JavaScript代码即可将功能完整的对话窗口嵌入网页,实现开箱即用的智能交互。文章重点讲解了核心部署步骤、会话隔离方案以及UI深度定制方法,帮助开发者快速打造贴合品牌、提升用户体验的网页AI助手。

gold8的专栏 583

【Codeforces】Chloe and the sequence (递归)

题解: 将序列写出来可以发现规律,1 + 2x 的位置值都是 1,2 + 4x 的位置的值都是 2,4 + 8x 的位置的数都是 3,8 + 16x 的位置的数都是 4……,因此按照这个规律就可以知道第k个数是谁了。并且由题意可以知道n到1的数量是逐渐增加的,可以利用递归函数进行取余从n向下查找这个元素是什么。 AC: #include<iostream> #include<cmath> #include<algorithm> using namespace st

skill_Carney的博客 571

Windows环境下ABAQUS、Fortran 编译器及Visual Studio的安装和关联

点击Continue,在随后的弹窗中勾选accept,并点击Customize(注意,在接下来的安装图片中,显示的版本号是2024.2,图片来自于一次失败的安装,懒得再截图了,步骤毫无区别,请见谅)。在下一步中,保持默认选项,之后软件会自动关联到刚才安装到visual studio,随后下一步进行安装(如果电脑中已经安装有其他版本的visual studio,则只保留2022)。在随后的弹窗中,根据指示找到。以防万一,尽量暂时退出所有杀毒软件,关闭防火墙,一般不会有影响,为确保万无一失,可以执行此步。

samurai12的博客 1万+

2026年软件测试职业院校技能大赛—ERP管理平台-采购入库模块Bug定位与查找

竞赛对接软件测试相关标准,以“ERP管理平台” 为被测系统,围绕软件测试领域的主流技术及工具,考查选手面 对实际问题的综合分析能力,对测试文档、测试用例的设计能力, 对单元测试、自动化测试、性能测试、接口测试等测试工具及方 法的掌握程度,检验选手团队协作能力、组织规划能力、方法运用能力等。

我是网络安全兼技能大赛工程师,专注网络安全技术学习与技能大赛实战!持续分享最新的技术文章,帮你少走弯路,一起在技术赛道上进步~ 219

CodeForces 83 D.Numbers(数论+递归)

Description 问区间[a,b][a,b][a,b]中以kkk为最小因子的数的个数,不考虑111为因子 Input 三个整数a,b,k(1≤a≤b≤2⋅109,2≤k≤2⋅109)a,b,k(1≤a≤b≤2⋅109,2≤k≤2⋅109)a,b,k(1\le a\le b\le 2\cdot 10^9,2\le k\le 2\cdot 10^9) Output 输出该区间中满足条件...

ZSQ 465

【机器学习】随机森林(Random Forest,简称 RF):预测光伏电站功率 || 缺失数据处理 || 重复行处理...

【机器学习】随机森林(Random Forest,简称 RF):预测光伏电站功率。

追光者♂:记录、分享、总结、提升,现象级专栏《Python从入门到人工智能》作者,无惧黑暗,坚信曙光 1662

Codeforces Round #354 (Div. 2)B.Pyramid of Glasses(思维题)

题目链接:http://codeforces.com/contest/676/problem/B B. Pyramid of Glasses time limit per test 1 second memory limit per test 256 megabytes input standard input output sta

hkh746392783的专栏 651

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

【CF 676B Pyramid of Glasses】模拟,递归

题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同。现在往最顶部的一个杯子倒 t 杯酒,求流动结束后有多少个杯子被装满。 思路:每个局部的两代三个杯子的流动过程是一致的,因此可以用递归来模拟求解。 具体为:设add(cur, i, l)执行“往第 i 个杯子倒cur量的酒”,附加...

weixin_30535043的博客 109

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Codeforces Round #354 (Div. 2) B. Pyramid of Glasses 模拟

B. Pyramid of Glasses 题目连接: http://www.codeforces.com/contest/676/problem/B Description Mary has just graduated from one well-known University and is now attending celebration party. Students like to ...

weixin_34242509的博客 115

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Codeforces Round #354 (Div. 2)676B. Pyramid of Glasses

题目链接:http://codeforces.com/problemset/problem/676/B 题意:有一个n层的酒杯架,每层有n个酒杯,样子跟图片一样。一个人倒酒t秒,一秒倒能装满一杯的酒,求t秒后有多少个满酒杯 思路: 暴力大法好 枚举一下每层的酒杯就好了#include<stdio.h> #include<string.h> #include<iostream> #includ

humeay的博客 406

Codeforces Round #354 (Div. 2) B. Pyramid of Glasses(模拟)

题目:http://codeforces.com/contest/676/problem/B 题意:有一个这样的杯子,第i层有i个杯子,从第一层开始倒酒,每秒倒出一杯的容量,问n层的杯子t秒有多少杯子“full” 思路:对于每个杯子模拟,第一个杯子放t杯酒,如何大于1,count++,然后每次除了原来的1,都向下流 代码:#include<bits/stdc++.h> using namesp

huatian5的博客 346

Codeforces1003 E. Tree Constructing(递归构造,cf2100)

【代码】Codeforces1003 E. Tree Constructing(递归构造,cf2100)

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 521

CodeForces 768 B.Code For 1(递归)

Description 初始序列只有nnn一个元素,每次操作会把序列中每个大于111的元素xxx变成⌊x2⌋,x%2,⌊x2⌋⌊x2⌋,x%2,⌊x2⌋\lfloor\frac{x}{2}\rfloor,x\%2,\lfloor\frac{x}{2}\rfloor,直至序列所有数字变成000或111为止,问操作结束后序列第lll个元素到第rrr个元素之间有多少111 Input 三个整数n,...

ZSQ 963

CodeForces 630C Lucky Numbers(递归)

C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output The numbers of all offices in the new bui

Shyazhut 621

Codeforces 1419B. Stairs 递归

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录前言一、pandas是什么?二、使用步骤1.引入库2.读入数据总结 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。 提示:以下是本篇文章正文内容,下面案例可供参考 一、pandas是什么? 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码

A_2Bpencils的博客 340

CodeForces - 50A Domino piling (贪心+递归)

CodeForces - 50A Domino piling (贪心+递归)题意分析奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0。代码#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #i

Pengwill's Blog 618

Codeforces Round #449 (Div. 1) A. Nephren gives a riddle 模拟.

A. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output What are you doing at the end of the world? Are you busy

now_ing的博客 321

Codeforces 560D Equivalent Strings(暴力递归)

题面 Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: They are equal. If we s...

Yi_Qing_Z的博客 374

Codeforces 897C(递归)

点击打开链接 扎心题,当时想法完全正确,姿势不对(思维不够细腻)没过。 题意:给出四个字符串x,y,f0,z,并且给出递推公式:fi=x+fi-1+y+fi-1+z,对于每次询问,输入两个数n和k,表示fn的第k个字符。 思路:k表示第fn的第k个字符,既然fn是由递推公式得来,那么k同样可以通过由递推公式得到,那么我们就可以由已知的k,通过递推公式往回推n次,这样就会得到fn中第k个对

沉醉不知归路 1065
上一篇: codeforces 676A Nicholas and Permutation
下一篇: ubuntu 无法使用 vim 系统剪贴板(或 :reg 无+号寄存器)
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址