当前位置:网站首页>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;
}
边栏推荐
- Hdu1228 a + B (map mapping)
- One trick to quickly realize custom application titlebar
- 最详细MySql安装教程
- Hdu1236 ranking (structure Sorting)
- 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)
- Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
- 高德根据轨迹画线
- Implement custom drawer component in quick application
- P1055 [noip2008 popularization group] ISBN number
- JSP webshell free -- webshell free
猜你喜欢

Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)

PHP tea sales and shopping online store
![[AI application] Hikvision ivms-4200 software installation](/img/4e/1640e3cafac13ce4d39520195c3217.png)
[AI application] Hikvision ivms-4200 software installation

Special topic of binary tree -- acwing 19 The next node of the binary tree (find the successor of the node in the tree)

QT learning diary 7 - qmainwindow

Win11 arm system configuration Net core environment variable

二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)

Creation and use of unified links in Huawei applinking

二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)

如何用list组件实现tabbar标题栏
随机推荐
QT学习日记8——资源文件添加
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
【付费推广】常见问题合集,推荐榜单FAQ
PCL point cloud to depth image
最详细MySql安装教程
Jsp webshell Free from killing - The Foundation of JSP
JSP webshell free -- webshell free
Approximate sum count (approximate
二叉树专题--AcWing 3384. 二叉树遍历(已知先序遍历 边建树 边输出中序遍历)
TIPC Service and Topology Tracking4
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
TIPC introduction 1
C# 文件与文件夹操作
V2X-Sim数据集(上海交大&纽约大学)
使用华为性能管理服务,按需配置采样率
TIPC Cluster5
Openmldb meetup No.4 meeting minutes
全网显示 IP 归属地,是怎么实现的?
Special topic of binary tree -- acwing 1589 Building binary search tree