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--pexpect
大家好,最近工作比较忙,所以没时间来更新博客.趁着还没在下个版本来临之前,来这边再更新更新.是之前学习到的一些老知识点,就当来巩固一下了.开心QAQ 今天给大家介绍的是--Pexpect Expect ...
- google云函数实现BigQuery数据操作
Google Cloud Function操作BigQuery数据库. 1.部署云函数时在配置文件中(package.json)添加一项 "@google-cloud/bigquery&qu ...
- C++继承权限
牢记两句话: 1.三种继承方式不影响子类对父类的访问权限,子类对父类的访问权限取决于父类的访问控制权. 2.三种继承方式是为了控制子类的调用方对父类的访问权限.比如private继承,对于子类的调用方 ...
- PHP.18-图片等比例缩放
图片等比例缩放 自定义函数ImageUpdateSize($pricname, $maxx, $maxy, $pre) 1.$pricname:被缩放的图片源(路径):2.$maxx,$maxy:缩放 ...
- 4x4矩阵键盘 扫描程序
一:不排除第四位异常处理 uchar JuzhenkeyScan() { // P3=0xfe; // temp=P3; // while(temp!=0xfe) // { // temp=P3; / ...
- 51Nod 1680 区间求和 树状数组
题意: 给出一个长度为\(n\)的数列\(A_i\),定义\(f(k)\)为所有长度大于等于\(k\)的子区间中前\(k\)大数之和的和. 求\(\sum_{k=1}^{n}f(k) \; mod \ ...
- 获取HTTP请求头中的地址
技术交流群:233513714 public static String getIpAddr(HttpServletRequest request) { String ip = request.get ...
- Column 'sort' specified twice错误
我使用的是mybatis框架出现的这个问题,如果你们也出现了这个问题的豪华,我想你们的sql代码一定是复制的吧,额哈哈哈
- Erlang OTP设计原则Gen_Fsm行为[转]
转自: http://www.cnblogs.com/yourihua/archive/2012/05/13/2497776.html 1. Fsm 称为 有限状态机,举个例子,游戏中的怪物称为NPC ...
- Lazarus教程 中文版后续给出
市面上有介绍Delphi的书籍(近来Delphi的书也是越来越少了),但没有一本系统的介绍Lazarus的书,这本书是网上的仅有的一本Lazarus教程,目前全部是英文,不过我已经着手开始翻译,争取尽 ...