Educational Codeforces Round 76 (Rated for Div. 2)F - Make Them Similar
题意:
给你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的更多相关文章
- Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest
Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以 ...
- 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 ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- Educational Codeforces Round 76 (Rated for Div. 2)E(dp||贪心||题解写法)
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序 ...
- Educational Codeforces Round 76 (Rated for Div. 2)
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #incl ...
- 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
- 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
- Educational Codeforces Round 76 (Rated for Div. 2) C. Dominated Subarray 水题
C. Dominated Subarray Let's call an array
- 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 ...
随机推荐
- [算法] Dijkstra算法(带权有向图 最短路径算法)
一.带权有向图 二.算法原理 1)由于我们的节点是从1-6,所以我们创建的列表或数组都是n+1的长度,index=0的部分不使用,循环范围为1-6(方便计算). 2)循环之前,我们先初始化dis数组和 ...
- eclipse创建java和web工程
JAVA Eclipse→File→New→Project.. WEB 右键mvn项目→Properties src/main/webapp pom.xml <project xmlns=&qu ...
- App工程结构
在经过千辛万苦各种填坑终于安装好了Android Studio之后,在其自带的模拟器上成功运行了第一个APP(hello world),通过这个APP首先研究了一下APP基本的工程结构,从而使后面的开 ...
- mysql设置编码格式--支持中文
创建table的时候就使用utf8编码 在每次创建表的时候都在最后加上 character set = utf8就可以很好的支持中文 create table xxx ( id int auto_in ...
- redis 5.0.7 源码阅读——字典dict
redis中字典相关的文件为:dict.h与dict.c 与其说是一个字典,道不如说是一个哈希表. 一.数据结构 dictEntry typedef struct dictEntry { void * ...
- kubernetes监控
总体设计思想 总体设计架构图Kubernetes monitoring architecture 设计介绍 监控分成两个部分 核心指标流程 包括的组件有 kubelet.resource estima ...
- 如何利用dokcer提交我的比赛代码
运气很好进入了天池的一个复赛,但是复赛评测时需要提交docker镜像,捣鼓了一个晚上,终于搞清了整套的流程.由于晚上已经下定决心要早点睡觉,害怕明早就会忘记的我还是先把步骤记录下来. 1. 安装doc ...
- 回炉重造之重读Windows核心编程-004-进程
进程是一个正在运行的程序的实例,由内核对象和地址空间组成.进程是不活泼的,执行地址空间中代码的是在它的环境中运行线程.每个线程都需要自己的一组CPU寄存器和堆栈. 为了让所有线程都能运行,操作系统就要 ...
- 离线部署ArcGIS Runtime for Android100.5.0
环境 系统:window 7 JDK:1.8.0_151 Maven:3.6.1 Android Studio:2.3 ArcGIS Runtime SDK for Android:100.5.0 1 ...
- C# WPF简况(2/3)
微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. C# WPF简况(2/3) 阅读导航 本文背景 代码实现 本文参考 1.本文背景 承接上文(C ...