题意:

  给你n个数字(<230),求出一个数字使得所有数字^这个数字之后,二进制状态下的1的个数相同。

解析:

  因为最大数字二进制数有30位,所以分为前15位和后15位,分别枚举0-1<<15,用map匹配。

代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map>
#include <set> using namespace std; typedef long long ll; const int maxn=+; ll a[maxn];
map<vector<int>, ll> mp; int main(){
ll n;
scanf("%lld",&n); for(int i=;i<n;i++)scanf("%lld",&a[i]);
for(int i=;i< (<<);i++){
vector<int> vd(n);
for(int j=;j<n;j++)vd[j]= __builtin_popcount( (a[j] & ) ^i)- __builtin_popcount((a[]&)^i);
if(not mp.count(vd))mp[vd]=i;
}
for(int i=;i< (<<);i++){
vector<int> vd(n);
for(int j=;j<n;j++)vd[j]= __builtin_popcount( (a[]>>) ^i)- __builtin_popcount( (a[j]>>) ^i);
if(mp.count(vd)){ printf("%lld\n",(i<<) + mp[vd]);
return ;
}
}
printf("-1\n");
return ;
}

  

Educational Codeforces Round 76 (Rated for Div. 2)F - Make Them Similar的更多相关文章

  1. Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest

    Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以 ...

  2. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  3. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  4. Educational Codeforces Round 76 (Rated for Div. 2)E(dp||贪心||题解写法)

    题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序 ...

  5. Educational Codeforces Round 76 (Rated for Div. 2)

    传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #incl ...

  6. Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest dp

    E. The Contest A team of three programmers is going to play a contest. The contest consists of

  7. Educational Codeforces Round 76 (Rated for Div. 2) D. Yet Another Monster Killing Problem 贪心

    D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of

  8. Educational Codeforces Round 76 (Rated for Div. 2) C. Dominated Subarray 水题

    C. Dominated Subarray Let's call an array

  9. Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick 水题

    B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes ...

随机推荐

  1. ORB-SLAM2 论文&代码学习 —— LoopClosing 线程

    转载请注明出处,谢谢 原创作者:Mingrui 原创链接:https://www.cnblogs.com/MingruiYu/p/12369339.html 本文要点: ORB-SLAM2 LoopC ...

  2. ASP .NET CORE 源码地址

    ASP .NET CORE 源码地址:https://github.com/dotnet/ 下拉可以查找相应的源码信息, 例如:查找 ASP .NET CORE Microsoft.Extension ...

  3. 利用MySQL之federated引擎实现DBLink功能

    有时候我们需要跨库join查询,但是配置多数据源成本又太高,Oracle提供了DBLink功能,MySQL中也有类似的实现:federated-engine. MySQL中使用federated引擎的 ...

  4. mysql删除索引

    删除索引 删除索引可以使用ALTER TABLE或DROP INDEX语句来实现.DROP INDEX可以在ALTER TABLE内部作为一条语句处理,其格式如下: drop index index_ ...

  5. JavaScript对象模型概念

    1.对象的概念 JavaScript只有函数对象才有类的概念,因此创建一个对象,必须使用函数对象.(ES6中可以直接声明一个class,实质上也是一个函数对象). 函数对象的内部有[[Construc ...

  6. servlet中使用request.getHeader("referer")获取页面从哪跳转过来的

    问题 servlet中使用request.getHeader("referer")获取页面从哪跳转过来的,利用这个方法可以判断网页是否正常登录.我做了一个javaweb小项目,其中 ...

  7. ClrFromCSharp_2_2_生成部署打包应用程序

    1,在\reps\CSharpFromCSarp\CSharpFromCSarp_2_2,建立新解决方案和解决项目 并且输入以下代码 namespace ClrFromCSharp_2_2 { cla ...

  8. npm 安装与部署

    nodejs 安装 查看版本 官方网址 下载linux版,64位 wget https://npm.taobao.org/mirrors/node/v12.13.1/node-v12.13.1-lin ...

  9. 用浏览器的油猴子脚本调用IDM下载百度云盘中的资料

    用浏览器的油猴子脚本调用IDM下载百度云盘中的资料(只能支持单个文件下载) 第一步需要现在浏览器中安装油猴子插件Tampermonkey.crx 安装油猴子插件插件主页:https://tamperm ...

  10. Windows添加管理员用户

    使用命令提示符添加用户并提升管理员权限 net user 查看当前所有系统用户 net user dan 123456 /add 添加用户名为dan 密码为123456的用户 net localgro ...