题意:

  给你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. 进阶之路 | 奇妙的Activity之旅

    前言 本文已经收录到我的Github个人博客,欢迎大佬们光临寒舍: 我的GIthub博客 本篇文章需要已经具备的知识: Activity的基本概念 AndroidManifest.xml的基本概念 学 ...

  2. linux安装python3环境并配置虚拟环境

    1.安装必要库 yum -y install gcc yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite- ...

  3. 阿里云服务器Web Deploy配置和使用Visual Studio进行Web项目发布部署遇到的坑

    阿里云的服务器一直闲着,烧着银子,当初花几千大洋开通,本想弄信息化的项目为所帮扶的贫困户脱贫助手,不想势单力薄,一直没有找到好的项目.最近大家都在众志成城抗击新肺疫情,于是又想能不能尽点自己的力量,于 ...

  4. linux 开机自启动redis服务

    [Unit] Description=The redis-server Process Manager Documentation=https://redis.io/ After=network.ta ...

  5. iMacros 入门教程-基础函数介绍(1)

    最近在研究 imacros 这工具,感觉非常强大,简单来说就是自动化对于浏览器的操作,程序自动帮你实现,支持 chrome firefox ie,这样基本就覆盖了99%的人群了吧,甚至他自己也有一个 ...

  6. 通过vsphere给esxi添加本地硬盘

    公司ESXi服务器的硬盘空间不够使用,现在新加了一块硬盘在ESxi服务器上.在服务器上添加完硬盘后,在Vsphere上是看不到新加硬盘的. 下面我们来通过虚拟机模拟该情况,先添加一块硬盘.如下图: 在 ...

  7. 牛客练习赛56 E 小雀和他的王国

    题目链接:https://ac.nowcoder.com/acm/contest/3566/E 思路:tarjan缩点,桥重建图,dfs跑树的直径. #include <iostream> ...

  8. 第2章.数组和ArrayList

    2.1 数组基本概念 数组是可索引的数据的集合.数组既可以是内置的类型,也可以是用户自定义的类型.事实上,把数组数据称为对象大概是最简便的方式.C#中数组实际上就是对象的本身,因为它们都源于Syste ...

  9. dsu on tree[树上启发式合并学习笔记]

    dsu on tree 本质上是一个 启发式合并 复杂度 \(O(n\log n)\) 不支持修改 只能支持子树统计 不能支持链上统计- 先跑一遍树剖的dfs1 搞出来轻重儿子- 求每个节点的子树上有 ...

  10. Enable VT-x in your BIOS security settings, ensure that HAXM is installed properly. Try disabling 3rd party security software if the problem still occurs

    win7系统安装了了AndroidStudio3.5后用模拟器报错:Enable VT-x in your BIOS security settings, ensure that HAXM is in ...