当前位置:网站首页>H. Maximal AND
H. Maximal AND
2022-04-22 20:26:00 【Bzdhxs_nt】
思路
知识点

记录每一位 1 1 1 的个数从高位到低位补 1 1 1 满 n n n
void solve(){
int n,k;
cin>>n>>k;
vector<int> a(n+1);
forr(i,1,n) cin>>a[i];
map<int,int> bit;
forr(i,1,n){
for(int j = 0; j < 31;j++){
if((a[i]>>j)&1) bit[j]++;
}
}
int ans = 0;
for(int j = 30;j>=0;j--){
if(k >= n - bit[j]){
ans += (1<<j);
k -= (n-bit[j]);
}
}
cout << ans << endl;
}
版权声明
本文为[Bzdhxs_nt]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_51687628/article/details/124346846
边栏推荐
- IAP之boot实现
- Tiktok + Shopify independent station evaluation, seller's new outlet
- 华为机试题——HJ72 百钱买百鸡问题
- Acrobat Pro DC tutorial, how to use password to protect PDF files?
- Self built CA center to issue certificates for different applications of the company
- Microservice architecture from 0 to 1, build the whole process record, hand-in-hand teaching, serialization
- Comparison and principle summary of golang local cache selection
- @Requestmapping get request parameters
- 华为机考题汇总
- 7-1 C语言程序设计 实验6-3 单向链表的插入 (30 分)
猜你喜欢

TikTok+Shopify独立站测评,卖家新风口.

Chapter 2 array

Module 4 operation

【建议收藏】面试没亮点

为了这一次字节跳动Android面试机会,我准备了158天,一个疏忽让我前功尽弃

时间戳转换

Connection method of Jincang database kingbasees

Timestamp conversion

7-1 C语言程序设计 实验6-3 单向链表的插入 (30 分)
![[untitled] leetcode 396 rotation function [finding laws in mathematics] the way of leetcode in heroding](/img/7a/c365daf5a61f02cb3cc8d7ec044283.png)
[untitled] leetcode 396 rotation function [finding laws in mathematics] the way of leetcode in heroding
随机推荐
Panyu maritime department has solidly promoted the 100 day action of safety education and training for water practitioners
Incorrect string value: ‘\xF0\x9F\x92\x95\’
396. Rotation function (mathematical law + iterative method)
Solve the problem of log printing when kingbasees inserts data into PG mode stand-alone database
MATLAB学习笔记 - 计算特征向量手动执行PCA
判断是否发生塑性变形的条件:von Mises屈服准则
Collection of microservice notes
启动kingbase单机服务时报错:invalid value for parmeter “bindcpulist”:”0-95”
虚拟机搭建安装Pulsar环境教程(开发测试使用)
CDH6.3.2 启用Kerberos 认证
木瓜移动课堂:产品更新,Facebook新增素材预审功能,力控广告违规~
2022 civil construction worker's question bank precision small question bank construction hall constructor
STM32 uses USB virtual serial port + ymodem to upgrade IAP
Error running ‘JeecgSystemApplication‘: Command line is too long. Shorten command line for JeecgSyst
leetcode222、完全二叉树的节点个数
sys_ When CTL starts Kingbase stand-alone service, an error is reported: could not bind IPv4 address "0.0.0.0": address already in use
2022年土建施工员题库精准小题库建设厅施工员
Improving fee shot part segmentation using course supervision
MySQL 第8章 数据库约束
Conditions for judging whether plastic deformation occurs: Von Mises yield criterion