当前位置:网站首页>Common properties of XOR and addition
Common properties of XOR and addition
2022-06-26 15:55:00 【Honestbutter-】
A. Meximum Array
Be careful :
- On the sequence a Each number in the must be operated once
- Addition and XOR have a common function : Change the parity of numbers , And the change of parity is synchronous
Odd number + Odd number = even numbers , Odd number ^ Odd number = even numbers
Odd number + even numbers = Odd number , Odd number ^ even numbers = Odd number
even numbers + even numbers = even numbers , even numbers ^ even numbers = even numbers - This topic has stated that : x x x and x + 3 x+3 x+3 One of them must eventually become y y y, Ask which can get , There is no process required . So we don't have to deduce the process carefully , Just find x , x + 3 , y x,x+3,y x,x+3,y Nature between .
- x x x and x + 3 x+3 x+3 Just one is an odd number , The other is even , Parity opposites , And we can just pass n One operation changes the parity of two numbers , If n After the first operation x x x and y y y It's different in parity , Description impossible .
- from 2 The derivation of is known , Both operations have the same effect on parity , So we can just ^ operation , Finally, judge the parity .
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long n,x,y;
cin>>n>>x>>y;
for(int i=1;i<=n;i++)
{
long long k;
cin>>k;
x^=k;
}
if((x%2)==(y%2)) puts("Alice"); // If parity is the same
else puts("Bob");
}
return 0;
}
边栏推荐
- golang 1.18 go work 使用
- svg环绕地球动画js特效
- Solana扩容机制分析(1):牺牲可用性换取高效率的极端尝试 | CatcherVC Research
- TweenMax+SVG切换颜色动画场景
- 学习内存屏障
- 【leetcode】331. 验证二叉树的前序序列化
- Solana扩容机制分析(2):牺牲可用性换取高效率的极端尝试 | CatcherVC Research
- Panoramic analysis of upstream, middle and downstream industrial chain of "dry goods" NFT
- CNN optimized trick
- Summary of data interface API used in word search and translation applications
猜你喜欢

Summary of students' learning career (2022)

How to create your own NFT (polygon) on opensea

Solana capacity expansion mechanism analysis (1): an extreme attempt to sacrifice availability for efficiency | catchervc research
![[problem solving] the loading / downloading time of the new version of webots texture and other resource files is too long](/img/31/d14316dca740590c1871efe6587e04.png)
[problem solving] the loading / downloading time of the new version of webots texture and other resource files is too long

JS creative icon navigation menu switch background color

Have you ever had a Kindle with a keyboard?

svg野人动画代码

HW安全响应

AbortController的使用

Keil4 opens the single-chip microcomputer project to a blank, and the problem of 100% program blocking of cpu4 is solved
随机推荐
Beijing Fangshan District specialized special new small giant enterprise recognition conditions, with a subsidy of 500000 yuan
Transformation of zero knowledge QAP problem
NFT transaction principle analysis (1)
js创意图标导航菜单切换背景色
STEPN 新手入門及進階
NFT交易原理分析(1)
AUTO sharding policy will apply DATA sharding policy as it failed to apply FILE sharding policy
JS creative icon navigation menu switch background color
简单科普Ethereum的Transaction Input Data
Secure JSON protocol
/etc/profile、/etc/bashrc、~/.bashrc的区别
On which platform is it safe to buy shares and open an account? Ask for guidance
TweenMax+SVG切换颜色动画场景
7 自定义损失函数
3 keras版本模型训练
Why are encoder and decoder structures often used in image segmentation tasks?
NFT transaction principle analysis (2)
8 自定义评估函数
Evaluation - TOPSIS
在哪个平台买股票开户安全?求指导