当前位置:网站首页>Rest (XOR) position and thinking
Rest (XOR) position and thinking
2022-07-02 11:11:00 【lcxdz】
Add link description
So if someone contributes , There must be someone in every paragraph 1, So we can consider from high to low , then b[j]=arr[j]&p Reverse operation Finally, judge whether the values are equal , If the number is even, it can be XOR cancelled
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+9;
int arr[N],b[N];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>arr[i];
int p=0;
for(int i=30;i>=0;i--){
p+=(1<<i);
for(int j=1;j<=n;j++)b[j]=arr[j]&p;// First & operation
int sum=0,d=0;
for(int j=1;j<=n;j++){
sum^=b[j];// Or else
if(sum==p){
d++;
sum=0;
}
}
if(sum==0&&d>=m&&(d-m)%2==0);// If the segment greater than is even, the XOR is 0 Equivalent
else p-=(1<<i);
}
cout<<p<<endl;
return 0;
}
边栏推荐
- 洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)
- 二叉树专题--AcWing 3384. 二叉树遍历(已知先序遍历 边建树 边输出中序遍历)
- PHP tea sales and shopping online store
- Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
- [applinking practical case] share in app pictures through applinking
- Filtering of PCL
- Special topic of binary tree -- [deep base 16. Example 7] ordinary binary tree (simplified version) (multiset seeks the precursor and subsequent sentry Art)
- 2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
- Resources读取2d纹理 转换为png格式
- [AI application] Hikvision ivms-4200 software installation
猜你喜欢
Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)
Implement custom drawer component in quick application
JVM之垃圾回收器
QT learning diary 7 - qmainwindow
Use of vscode tool
三.芯片启动和时钟系统
Special topic of binary tree -- acwing 3384 Binary tree traversal (known preorder traversal, while building a tree, while outputting middle order traversal)
TIPC 寻址2
Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
随机推荐
[quick application] win7 system cannot run and debug projects using Huawei ide
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
The difference between self and static in PHP in methods
The most detailed MySQL installation tutorial
Oracle notes
PCL eigen introduction and simple use
TIPC messaging3
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
From Read and save in bag file Jpg pictures and PCD point cloud
Use of vscode tool
[applinking practical case] share in app pictures through applinking
QT学习日记7——QMainWindow
MySQL lethal serial question 4 -- are you familiar with MySQL logs?
Static variables in static function
Calculate the sum of sequences
JSP webshell free -- the basis of JSP
华为AppLinking中统一链接的创建和使用
PCL extracts a subset from a point cloud
QT learning diary 8 - resource file addition