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 ...
随机推荐
- expect配合shell 实现自动分发秘钥文件
expect使用场景 有时候需要批量地执行一些操作,或者执行自动化的操作的时候,有些指令需要交互式地进行这就会有很多麻烦,linux下有一个程序交expect,它可以模拟键盘输入文本,省去人工干预交互 ...
- LVM(扩展)
LVM(扩展)======================== [root@aminglinux newdir]# fdisk -l /dev/sdb 磁盘 /dev/sdb:10.7 GB, 107 ...
- linux上面安装svn步骤
一.安装 使用yum,非常简单 yum install subversion 二.配置 2.1.创建仓库 我们这里在/home下建立一个名为svn的仓库(repository),以后所有代码都放在这个 ...
- python 获取类中除内置方法外的所有方法名
#!/usr/bin/env python# !-*- coding:utf-8 -*- class Menu: def __init__(self): pass def updateProject( ...
- TouTiao开源项目 分析笔记7 加载数据的过程
1.以新闻页中的段子数据显示为例 1.1.首先执行InitApp==>SplashActivity. 因为在AndroidManifest.xml中定义了一个<intent-filter& ...
- css一些事儿
1. margin和padding 如果边界画一条线,则margin的属于边界外,padding属于边界内 当我们给元素背景色时,margin区域不会被着色,而padding区域会被着色. 当上下两个 ...
- Java - 收藏集 -
Java - 收藏集 - Java 基础思维导图,让 Java 不再难懂 - 工具资源 - 掘金思维导图的好处 最近看了一些文章的思维导图,发现思维导图真是个强大的工具.了解了思维导图的作用之后, ...
- 【Regularization】林轩田机器学习基石
正则化的提出,是因为要解决overfitting的问题. 以Linear Regression为例:低次多项式拟合的效果可能会好于高次多项式拟合的效果. 这里回顾上上节nonlinear transf ...
- Jmeter编码问题
问题现象:1.利用csv data set config参数化数据后,在beanshell中引用,能正常引用到,但是传给服务器时,还是报手机号格式不对 将jmeter日志级别打成debug(jmete ...
- operator、explicit与implicit
说这个之前先说下什么叫隐式转换和显示转换 1.所谓隐式转换,就是系统默认的转换,其本质是小存储容量数据类型自动转换为大存储容量数据类型. 例如:float f = 1.0: double d=f:这样 ...