当前位置:网站首页>Niuke practice 101-c reasoning clown - bit operation + thinking
Niuke practice 101-c reasoning clown - bit operation + thinking
2022-06-27 05:03:00 【Wawa source】

The topic requires a minimum value , According to greedy thought , In the case of binary representation , High position 1 The less, the better.
#include<iostream>
using namespace std;
const int N = 100010;
int a[N];
int res=0;
int main()
{
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int j=30,i;j>=0;j--)// Traverse every bit , Suppose this bit is 0, If the conditions are not met, you must select , by 1
{
int t=res;
// Look at number j Position as 0 Whether the conditions are met in the case of
for(int k=j-1;k>=0;k--)
{
t|=1<<k;
// dissatisfaction break, This must be > Number
for(i=1;i<n;i++)if((a[i]&t)>(a[i+1]&t))break;
// Not satisfied to prove that this person cannot be 1, XOR becomes original value at once
if(i!=n)t^=1<<k;
}
// Judge whether it is satisfied , Does not meet the requirements of article of the certificate j Bit must be 1
for(i=1;i<n;i++)if((a[i]&t)>=(a[i+1]&t))break;
if(i!=n)res|=1<<j;
}
cout<<res<<'\n';
}
边栏推荐
- Interview: what are the positioning methods in selenium? Which one do you use most?
- 008 C语言基础:C判断
- 019 C语言基础:C预处理
- unity点光源消失
- Office VR porn, coquettish operation! The father of Microsoft hololens resigns!
- 渗透测试-文件上传/下载/包含
- Pytest框架的执行规则
- 【C语言】关键字的补充
- 006 C language foundation: C storage class
- 013 basics of C language: C pointer
猜你喜欢

【B站UP DR_CAN学习笔记】Kalman滤波1

关于元器件封装的一些文章和一下我的体会

neo4j图数据库基本概念

1.5 conda的使用

Penetration test - file upload / download / include

Système de collecte des journaux

Cultural tourism night tour | stimulate tourists' enthusiasm with immersive visual experience
![[array]bm94 rainwater connection problem - difficult](/img/2b/1934803060d65ea9139ec489a2c5f5.png)
[array]bm94 rainwater connection problem - difficult

Learn crypto from Buu (Zhou Geng)

Microservice system design -- service registration, discovery and configuration design
随机推荐
012 C language foundation: C array
EPICS记录参考5 -- 数组模拟输入记录Array Analog Input (aai)
Edge在IE模式下加载网页 - Edge设置IE兼容性
jq怎么获取元素的id名
【B站UP DR_CAN学习笔记】Kalman滤波1
006 C language foundation: C storage class
Edge loads web pages in IE mode - edge sets ie compatibility
Microservice system design -- microservice monitoring and system resource monitoring design
halcon常用仿射变换算子
010 C语言基础:C函数
从某种意义来讲,互联网业已成为了一个孵化器,一个母体
高等数学(第七版)同济大学 习题1-10 个人解答
007 basics of C language: C operator
math_数集(数集符号)和集合论
math_ Number set (number set symbol) and set theory
高翔slam14讲-笔记1
stm32读取IO高低电平状态
Interview: what are the positioning methods in selenium? Which one do you use most?
微服务系统设计——微服务监控与系统资源监控设计
021 C语言基础:递归,可变参数