当前位置:网站首页>3537. Tree lookup
3537. Tree lookup
2022-07-22 02:09:00 【Ray. C.L】
Ideas : The first k The starting point of the layer is 2 k − 1 − 1 The length of this layer is 2 k − 1 , The first k The starting point of the layer is 2^{k-1}-1 The length of this layer is 2^{k-1} , The first k The starting point of the layer is 2k−1−1 The length of this layer is 2k−1, This is the property of a complete binary tree
The difficulty of these machine test questions is really beyond words
Code :
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
int n, k;
int w[N];
int main()
{
int n, k;
cin >> n;
for(int i = 0; i < n; i ++) cin >> w[i];
cin >> k;
int s = (1 << k - 1) - 1, e = s + (1 << k - 1);
for(int i = s; i < e && i < n; i ++)
cout << w[i] << ' ';
if(s >= n)
cout << "EMPTY" << endl;
return 0;
}
边栏推荐
- 机器学习岗位面试总结:简历应该关注的5个重点
- [深度学习学习笔记]注意力机制-Attentional mechanism
- 奇葩!一公司面试题竟问如厕习惯、吃饭时长、入睡时间等
- Database generates HTML document
- 第3章业务功能开发(实现显示线索主页面,并查询表单各个下拉框数据)
- 腾讯 Techo Hub 2022 年首站落地福州|723,与开发者们探讨工业数字化!
- MQTT源码解析
- 08. Merge sort and quick sort
- import torch_ geometric. NN error /lib64/libm so. 6: version `GLIBC_ 2.27‘ not found
- weirdo A company's interview questions asked about toilet habits, eating time, sleeping time, etc
猜你喜欢
左耳朵耗子:云原生时代的开发者应具备的5大能力
import torch_ geometric. NN error /lib64/libm so. 6: version `GLIBC_ 2.27‘ not found
6.< tag-动态规划和打家劫舍合集(树形DP)>lt.198.打家劫舍 + lt.213. 打家劫舍 II + lt.337. 打家劫舍 III dbc
风控系统,Flink+Clickhouse实现!
rust中的静态分发和动态分发
【学术相关】陈天奇、王威廉等人推荐:ACL最佳论文奖得主给新入行研究者的一点建议...
Pix2Seq:谷歌大脑提出 CV 任务统一接口!
sql中substr与substring函数用法
童年的回忆小游戏来了——贪吃蛇,快来自己动手写一个属于自己的小游戏吧
m基于中继协助的认知无线电频谱切换机制的matlab仿真分析
随机推荐
安全之路 —— 单管道反向连接后门解析
The sum of the last three numbers
have a look
浅谈牛顿迭代
import torch_geometric.nn报错/lib64/libm.so.6: version `GLIBC_2.27‘ not found
Codeforces Round #806 (Div. 4) D(DP,特判大数)
基于三维GIS的场数据模型研究与实践
Matlab simulation analysis of spectrum switching mechanism of cognitive radio based on relay assistance
Musk uploaded his brain to the cloud? Zhou Hongyi: we have to use human brain security guards to kill poison
[academic related] recommended by Chen Tianqi, Wang William and others: a little advice from the winner of ACL best paper award to new researchers
Number game: n people count off, those who report a multiple of 3 leave, and the rest continue
MySQL installed in MAC M1, enable binlog
架构模式 节选自《闻缺陷则喜》(此书可免费下载)
第二章 软件过程与思想 第一节 基础
How to use the order flow analysis tool (Part 1)
js对象:实现继承的几种方式及优缺点
利用正则回溯最大次数上限进行绕过
Codeforces Round #809 (Div. 2) - C, D1
Gateway整合Sentinel实现对路由的限流规则
NepCTF2022 WP