ACdream 1023 抑或
Xor
Problem Description
For given multisets Aand B, find minimum non-negative xx which A⊕x=BA⊕x=B
Note that for A={a1,a2,…,an}A={a1,a2,…,an} , A⊕x={a1⊕x,a2⊕x,…,an⊕x}. ⊕stands for exclusive-or.
Input
The first line contains a integer nn , which denotes the size of set AA (also for BB ).
The second line contains nn integers a1,a2,…,ana1,a2,…,an , which denote the set AA .
The thrid line contains nn integers b1,b2,…,bnb1,b2,…,bn , which denote the set BB .
(1≤n≤1051≤n≤105 , nn is odd, 0≤ai,bi<2300≤ai,bi<230 )
Output
The only integer denotes the minimum xx . Print −1−1 if no such xx exists.
Sample Input
3
0 1 3
1 2 3
Sample Output
2
Source
Manager
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<cmath>
#define ll long long
#define pi acos(-1.0)
#define mod 1000000007
using namespace std;
int ans1,ans2;
int a[];
int b[];
int exm;
int sum1=,sum2=;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
ans1=ans2=;
sum1=;
sum2=;
for(int i=;i<=n;i++)
{
scanf("%d",&exm);
a[i]=exm;
ans1=ans1^exm;
}
for(int i=;i<=n;i++)
{
scanf("%d",&exm);
b[i]=exm;
sum2+=exm;
ans2=ans2^exm;
}
ans1=ans1^ans2;
for(int i=;i<=n;i++)
{
sum1=sum1+(ans1^a[i]);
}
if(sum1==sum2)
cout<<ans1<<endl;
else
cout<<"-1"<<endl;
}
return ;
}
ACdream 1023 抑或的更多相关文章
- ACdream 1214---矩阵连乘
ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- acdream.Bet(数学推导)
Bet Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Status Pra ...
- acdream.郭式树(数学推导)
郭式树 Time Limit:2000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit Status Pr ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- ACdream 1195 Sudoku Checker (数独)
Sudoku Checker Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- ACdream 1112 Alice and Bob(素筛+博弈SG函数)
Alice and Bob Time Limit:3000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit ...
随机推荐
- python导包学习总结
python初学者,对于导包纠结了不少时间,总结分享,持续前进~ Python导包的两种方法: 1.1 from 包.模块 import 方法名,调用时直接使用方法名() 1.2 from 包. ...
- 给网站添加icon图标
只需制成ico结尾的图片即可
- 4.1 基本类型和引用类型的值【JavaScript高级程序设计第三版】
ECMAScript 变量可能包含两种不同数据类型的值:基本类型值和引用类型值.基本类型值指的是简单的数据段,而引用类型值指那些可能由多个值构成的对象. 在将一个值赋给变量时,解析器必须确定这个值是基 ...
- Lo、Hi、HiByte、LoWord、HiWord、MakeWord、MakeLong、Int64Rec
本话题会涉及到: Lo.Hi.HiByte.LoWord.HiWord.MakeWord.MakeLong.Int64Rec 譬如有一个 Cardinal 类型的整数: 1144201745其十六进制 ...
- iOS-重构微博cell模型
一.Frame模型: -------------------WeiboFrame.h-------------------------------------------------- ------- ...
- 关于Java对象作为参数传递是传值还是传引用的问题
前言 在Java中,当对象作为参数传递时,究竟传递的是对象的值,还是对象的引用,这是一个饱受争议的话题.若传的是值,那么函数接收的只是实参的一个副本,函数对形参的操作并不会对实参产生影响:若传的是引用 ...
- 17-比赛1 B - 子串计算 Chef and his string challenge (string的运用)
Chef's best friend Jerry gives Chef a string A and wants to know the number of string A that can be ...
- 您的手机上未安装应用程序 android 点击快捷方式提示未安装程序的解决
最近APP出现一个很奇怪的问题,在Android 4.4.2和android 4.4.3系统上点击应用的快捷方式,打不开应用,而且会提示未安装程序. 确认了应用的MainActivity中设置了and ...
- 安装macports
Mac下面除了用dmg.pkg来安装软件外,比较方便的还有用MacPorts来帮助你安装其他应用程序,跟BSD中的ports道理一样.MacPorts就像apt-get.yum一样,可以快速安装些软件 ...
- 把现有Unity3d游戏向Windows Phone 8.1移植(基础)
最近在将一款现有的游戏向Windows Phone平台移植,暂时完成了一个小阶段,做一个总结. 开发环境: Windows 8.1 系统及以上,愿意的话,用Windows 10 尝鲜也可以. 微软账号 ...