当前位置:网站首页>Niuke - Practice 101 - reasoning clown
Niuke - Practice 101 - reasoning clown
2022-07-01 23:51:00 【why151】
Reasoning clown
Title Description
Main idea :
This problem is mainly solved by an attempt .
Try from high to low .
If the high position can not be 1 Just be satisfied < Words , Then don't be high 1;
If the high position is not 1 Will appear > Words , Then the high position must be 1;
If appear = In the case of , Need to look back , If you can't, then 1.
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int n;
int a[N];
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
int ans=0;
for(int i=30;i>=0;i--)
{
int now=ans;
bool flag;
for(int j=i-1;j>=0;j--)
{
now|=1<<j;
flag=1;
for(int k=1;k<n;k++) {
if((a[k]&now)>(a[k+1]&now))
{
flag=0;
break;
}
}
if(!flag) now^=1<<j;
}
flag=1;
for(int k=1;k<n;k++)
{
if((a[k]&now)>=(a[k+1]&now))
{
flag=0;
break;
}
}
if(!flag) ans|=1<<i;
}
cout<<ans<<endl;
return 0;
}
边栏推荐
- [LeetCode] 最后一个单词的长度【58】
- Regular expression collection
- vs2015 AdminDeployment. xml
- 【QT】Qt 使用MSVC2017找不到编译器的解决办法
- Li Kou today's question -241 Design priorities for operational expressions
- 【ES实战】ES上的安全性运行方式
- 【QT】对于Qt MSVC 2017无法编译的问题解决
- Why does blocprovider feel similar to provider?
- 记录一下大文件上传偶然成功偶然失败问题
- Postgresql随手记(10)动态执行EXECUTING语法解析过程
猜你喜欢
kubernetes资源对象介绍及常用命令(三)
Write some suggestions to current and future doctoral students to sort out and share
关联性——组内相关系数
Redis 主从同步
- Oui. Env. Fichier XXX, avec constante, mais non spécifié
起床困难综合症(按位贪心)
[QT] qtcreator uninstall and installation (abnormal state)
Use pair to do unordered_ Key value of map
Redis AOF log
字典、哈希表、数组的概念
随机推荐
. env. XXX file, with constant, but undefined
[LeetCode] 最后一个单词的长度【58】
记录一下大文件上传偶然成功偶然失败问题
Selectively inhibiting learning bias for active sampling
Redis RDB snapshot
电商RPA机器人,助力品牌电商抢立流量高点
PostgreSQL notes (10) dynamically execute syntax parsing process
ConcurrentSkipListMap——跳表原理
在代码中使用SqlCommand对象
安全协议重点
Iota in golang
Postgresql随手记(10)动态执行EXECUTING语法解析过程
How excel opens CSV files with more than one million lines
Regular expression collection
起床困难综合症(按位贪心)
【QT】對於Qt MSVC 2017無法編譯的問題解决
Windows 7 安装MYSQL 错误:1067
Postgresql源码(58)元组拼接heap_form_tuple剖析
kubernetes资源对象介绍及常用命令(三)
[swoole Series 1] what will you learn in the world of swoole?