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的更多相关文章

随机推荐

  1. git简单使用指南

    git - 简易指南 这是一篇最适合初学者的教程,这里面没有高深的内容.学习git它可以帮助你管项目代码,提高团队开发效率.我使用的是win10系统,这里我会用它来给大家讲解. git - 安装 安装 ...

  2. 2018铁人三项测评题 IOS99

    下面这一部分是我从网上复制过来的, 2.IOS 解题链接:http://ctf4.shiyanbar.com/web/IOS/index.php 这题页面中提示系统升级到了IOS99,我们可以想到修改 ...

  3. 通过httpClient设置代理Ip

    背景: 我们有个车管系统,需要定期的去查询车辆的违章,之前一直是调第三方接口去查,后面发现数据不准确(和深圳交警查的对不上),问题比较多.于是想干脆直接从深圳交警上查,那不就不会出问题了吗,但是问题又 ...

  4. 在浏览器窗口内移动的div

    ------------今天研究了一个最简单的屏保效果----------- 效果图如下:效果很神奇,就是这个div在浏览器窗口不断的灵活移动 代码却很简单 <!DOCTYPE html> ...

  5. netcore使用IOptions

    { "Logging": { "LogLevel": { "Default": "Information", " ...

  6. Prometheus+Alertmanager+Grafana监控组件容器部署

    直接上部署配置文件 docker-compose.yml version: '3' networks: monitor: driver: bridge services: prometheus: im ...

  7. JSON的学习与使用

    .katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...

  8. 19南京网络赛B 欧拉降幂

    题目链接 给a,b,p.有b个a的幂 #include <iostream> using namespace std; typedef long long LL; const LL N = ...

  9. PythonI/O进阶学习笔记_11.python的多进程

    content: 1. 为什么要多进程编程?和多线程有什么区别? 2. python 多进程编程 3. 进程间通信 =======================================   ...

  10. CCPC-Wannafly Winter Camp Day 1

    B. 密码学 题意: 告诉你关于字符串加密的方法,然后给你一些加密操作和加密后的字符串,让你求原来的串 思路: 知道被加密后的串与加密字符可以向前推出被加密之前的串,不断向前模拟即可 #include ...