Codeforces_734_F
http://codeforces.com/problemset/problem/734/F
x|y + x&y = x+y。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; long long a[],b[],c[],num[] = {};
int n; int main()
{
scanf("%d",&n);
long long sum = ;
for(int i = ;i <= n;i++)
{
scanf("%I64d",&b[i]);
sum += b[i];
}
for(int i = ;i <= n;i++)
{
scanf("%I64d",&c[i]);
sum += c[i];
}
int flag = ;
if(sum%(*n)) flag = ;
else
{
sum /= *n;
for(int i = ;i <= n;i++)
{
long long t = b[i]+c[i];
if((t-sum)%n)
{
flag = ;
break;
}
else a[i] = (t-sum)/n;
}
}
if(flag)
{
for(int i = ;i <= n;i++)
{
for(int j = ;(<<j) <= a[i];j++)
{
if(a[i]&(<<j)) num[j]++;
}
}
for(int i = ;i <= n;i++)
{
long long t = ;
for(int j = ;(<<j) <= a[i];j++)
{
if(a[i]&(<<j)) t += num[j]*(1LL<<j);
}
if(t != b[i]) flag = ;
}
}
if(flag)
{
for(int i = ;i <= n;i++) printf("%I64d ",a[i]);
printf("\n");
}
else printf("-1\n");
return ;
}
Codeforces_734_F的更多相关文章
随机推荐
- day4(dict和set)
dict 内置字典,使用key-value存储,具有极快的查找速度. >>>d = {'michael': 95, 'bob': 75, 'tracy': 85} >>& ...
- window 下配置wamp 环境
PHP下载 下载php压缩包,几点注意:这里我安装的事apache 所以在 php官方下载页时不是随便下载的,不然可能配置不了apache! 注意我以下图片标注
- 12.pyecharts详细使用教程
官方数据教程: 柱状图-Bar //导入柱状图-Bar from pyecharts import Bar //设置行名 columns = ["Jan", "Feb&q ...
- Java读取数据库中的xml格式内容,解析后修改属性节点内容并写回数据库
直接附代码: 1.测试用的xml内容 <mxGraphModel> <root> <mxCell id="-1" /> <mxCell i ...
- 抽象工厂模式(C++)
#include <iostream> using namespace std; class Fruit { public: ; }; class AbstractFactory { pu ...
- WIN10升级后输入法无法输入中文
查看是否安装了中文输入法,可能在升级后用户文件出现问题. 在设置>语言.添加一下中文输入法.
- VMware Workstation CentOS7 Linux 学习之路(3)--.net coreWeb部署
1.首先创建一个文件夹,命名为core mkdir core cd core 2.我这里用FlashFXP连接Linux 把我发布的项目上传到CentOS7的core文件夹下 此时我输入命令 dotn ...
- org.springframework.core.type.classreading.ClassMetadataReadingVisitor 异常
今天项目启动的时候发现了一个异常: Exception in thread "main" org.springframework.beans.factory.BeanDefinit ...
- python小知识点总结
小知识点总结 1.python2和python3的区别 python2 python3 默认编码 ascii utf-8 input() raw_input() input() print 可以不 ...
- mysql 执行计划和慢日志记录
一.执行计划 1.作用预估sql语句执行的时间,一般准确2.格式: explain sql语句3.type类型的快慢(all最慢,const最快)all < index < range & ...