题意:

  给你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. 献给即将35岁的初学者,焦虑 or 出路?

    导言:“对抗职场“35 岁焦虑”,也许唯一的方法是比这个瞬息万变的商业社会跑得更快!” 一直以来,都有许多人说“程序员或测试员是个吃青春饭的职业”,甚至还有说“35 岁混不到管理就等于失业”的言论. ...

  2. ES6学习笔记(二):教你玩转类的继承和类的对象

    继承 程序中的继承: 子类可以继承父类的一些属性和方法 class Father { //父类 constructor () { } money () { console.log(100) } } c ...

  3. 剑指offer-面试题63-股票的最大利润-数组

    /* 题目: 给定一个股价序列,求一次交易的最大利润. */ #include<iostream> #include<vector> using namespace std; ...

  4. nginx配置访问https[自签版]

    通过openssl生成证书 (1)设置server.key,这里需要设置两遍密码: openssl genrsa -des3 -out server.key 1024 (2)参数设置,首先这里需要输入 ...

  5. OBS使用教程

    OBS使用教程 OBS使用教程:录屏热键的设置 视频:基础画布分辨率1920/1080 1366,768输出缩放分辨率常用FPS值 30或者60 输出:输出模式:高级录像:编码器x264码率控制 CB ...

  6. C#XML文件操作随笔

    以为公司一直没有电源屏厂家协议解析为DevVars相关的软件,手写费时费力还容易出错,用了2天时间做了一个.txt协议文件筛选加并解析成xml文件的工具,总结一下用到的几个知识点 1.LINQ 是一个 ...

  7. Windows2008R2 一键安全优化脚本

      ::author vim ::QQ 82996821 ::filename Windows2008R2_safe_auto_set.bat   :start @echo off color 0a ...

  8. 使用JAVA导出EXCEL表格(POI)

    一.POI概述 Jakarta POI 是一套用于访问微软格式文档的Java API.POI提供API给Java程序对Microsoft Office格式档案读和写的功能.在许多企业办公系统中,经常会 ...

  9. Spring中@Value用法

    Spring中可以通过@Value注解,将properties配置文件中的属性值注入到java成员变量,配置和使用方法如下(大部分转自csdn,也有自己实验部分): 一.配置 首先,@value需要参 ...

  10. DOM基础+domReady+元素节点类型判断

    DOM节点类型  nodeType element  1    Node.ELEMENT_NODE   元素节点 attr  2   Node.ATTRIBUTE_NODE  属性节点 text  3 ...