codeforces 676B Pyramid of Glasses 递归

XDMA原理学习(1)——DMA技术详解 DMA 技术是Direct Memory Access的缩写,其意思是“存储器直接访问”。它是指一种高速的数据传输操作,允许在外部设备和存储器之间直接读写数据,既不通过CPU,也不需要CPU干预。DMA是所有现代计算机的重要特色,它允许不同速度的硬件设备进行沟通,而不需要依于中央处理器的大量中断负载。否则,中央处理器需要从来源把每一片段的数据复制到寄存器,然后把它们再次写回到新的地方。在这个时间里,中央处理器就无法执行其它的任务。 阅读详情

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;
}




风电功率预测项目技术白皮书:短期、超短期、中长期全尺度算法详解与工程落地 聚焦风电功率预测的时间尺度与算法:短期(0~72h)以XGBoost/LightGBM/CatBoost及深度学习为主,超短期(0~4h)采用ARMA+LSTM,中长期用LightGBM等,并涵盖概率预测、多气象源融合、AI大模型+物理模型混合策略、极端天气应对及工程运维要点。 阅读详情

相关推荐

基因组注释(Annotation)

Annotation

hgz2020的博客 6485

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

ANSYS_APDL实战入门——从零开始掌握模态分析

本文为ANSYS APDL模态分析实战入门指南,通过一个悬臂梁案例,手把手教你从零开始掌握APDL命令流。内容涵盖从模型创建、材料定义、网格划分到边界条件设置、求解及后处理结果查看的全流程,帮助工程师快速上手结构动力学分析,避免共振风险。

egg99的博客 1128

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的博客 628

喷雾破碎模型解析:从理论到CFD应用实践

本文深入解析喷雾破碎模型的理论基础与CFD应用实践,重点介绍KHRT、TAB和ETAB等主流模型的核心原理与工程调参技巧。通过OpenFOAM实例演示和参数优化建议,帮助工程师精准预测液滴破碎行为,提升燃烧效率与排放控制性能,适用于汽车发动机、燃气轮机等工业场景。

weixin_29281915的博客 497

树莓派4B+Ubuntu22.04+思岚RPLIDAR C1激光雷达应用

树莓派+Ubuntu22.04+思岚RPLIDAR C1激光雷达简单应用

techfuture的博客 3703

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 801

思科路由器、交换机组网实验报告

通过思科模拟器搭建路由交换网络

ghj528的博客 1334

【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

Dify知识库文档批量下载神器:一键导出所有文件到本地

在使用Dify进行知识库管理的过程中,我们经常遇到一个实际问题:如何将已上传到知识库中的文档批量下载到本地?目前Dify的管理界面虽然功能强大,但暂时没有提供直接的UI界面来批量导出或下载知识库内的文档。这意味着如果我们需要将知识库中的文件备份到本地或进行离线处理,只能通过API接口来实现。本文将详细介绍如何利用Dify的REST API构建一个完整的知识库文档下载解决方案,这也是目前实现知识库文件批量下载到本地的唯一可行路径。🎉进入大模型应用与实战专栏 | 🚀查看更多专栏内容首先,我们需要在Dify的

羊城迷鹿的博客 3473

Android功耗系列专题分析之四:待机概率性功耗高的失效分析

本文分析了Android设备待机功耗异常高的问题。通过日志发现系统休眠失败,原因是PowerManagerService.Display唤醒锁未被释放。进一步排查发现,指纹解锁功能在灭屏时未正确释放屏幕锁定,导致DisplayReady状态异常。解决方案是将指纹功能的背光控制与DisplayReady状态控制分离,使用两个变量独立管理。经验表明,快速定位问题比解决问题更重要,修改原生流程时需谨慎评估风险。

451

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 462

【电源专题】案例:对比不同电池在不同电流下的电池放电曲线

无

一点硬件 2840

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的专栏 650

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

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

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

weixin_30535043的博客 109

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

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的博客 114

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

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的博客 405

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 961

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 617

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 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 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的博客 373

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 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、付费专栏及课程。

余额充值