当前位置:网站首页>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;
}
边栏推荐
- 如何使用IDE自动签名调试鸿蒙应用
- 【深入浅出玩转FPGA学习4----漫谈状态机设计】
- [applinking practical case] share in app pictures through applinking
- Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
- [ark UI] implementation of the startup page of harmonios ETS
- Approximate sum count (approximate
- Huawei game failed to initialize init with error code 907135000
- [play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]
- Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)
- Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
猜你喜欢

MTK full dump抓取

JSP webshell free -- the basis of JSP

2022爱分析· 国央企数字化厂商全景报告

一招快速实现自定义快应用titlebar
![Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)](/img/dc/2aa55c9b3f23c292820a56ea72fedd.png)
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)

TIPC 寻址2

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

From Read and save in bag file Jpg pictures and PCD point cloud

PKG package manager usage instance in FreeBSD

使用华为性能管理服务,按需配置采样率
随机推荐
【深入浅出玩转FPGA学习3-----基本语法】
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
How to use ide to automatically sign and debug Hongmeng application
Flink two Open, implement Batch Lookup join (attached source)
Regular and common formulas
TIPC Service and Topology Tracking4
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
TIPC Service and Topology Tracking4
[AI application] Hikvision ivms-4200 software installation
PCL extracts a subset from a point cloud
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)
P1055 [noip2008 popularization group] ISBN number
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
二叉树专题--AcWing 1589. 构建二叉搜索树
Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
华为AppLinking中统一链接的创建和使用
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
Leetcode 182 Find duplicate email (2022.07.01)
Uncover the secrets of Huawei application market application statistics
Use Huawei performance management service to configure the sampling rate on demand