题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0,其他位随意填写,恰好弄出n-1个数来,然后对这n-1个数求xor和,记作sum,再输出x xor sum即可.由于只有最后一个数的该位为1,所以必然可以保证不重. 如果x为0: 如果n不能被4整除,那么输出0 ~ n-2,然后记这些数的异或和为sum,再输出(1<<18)|sum,以及1<&…
题意:交互题:存在一个至少有一个0和一个1的长度为n的二进制串,你可以进行最多15次询问,每次给出一个长度为n的二进制串,系统返回你此串和原串的海明距离(两串不同的位数).最后要你找到任意一个0的位置和任意一个1的位置. 先问n个0,返回你的原串中是1的数量,记为X.然后将任意一位改成1,倘若答案增量为1,那么你改动的那位在原串中是0,反之,那位是1. 不失一般性地,我们假设你改动的那一位在原串中是0,你就要去找1的位置. 就不断二分缩小区间,每次将当前区间划分成左右两部分l,m m+1,r.如…
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. Mahmoud and Ehab and the MEX[水] 题意:定义一个集合的MEX为其中的最小的不在集合里的非负整数,现在给一个大小为N的集合和X,每次操作可以向其中加入一个非负整数或删除一个数,问最小的操作次数,使得这个集合的MEX为X. #include<cstdio> #include…
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN]; int main(void) //Codeforces Round #…
CF比赛题目地址:http://codeforces.com/contest/862 A. Mahmoud and Ehab and the MEX ·英文题,述大意:      输入n,x(n,x<=100),然后输入n个数作为一个集合.现在可以进行多次操作,每次操作为删除一个数或者添加一个数,求最少操作数使得集合Mex值等于x. ·分析:      也许是考察Mex的吧~那就当复习了,我们的策略是,如果当前集合的  Mex比x小,那就一直添加数;如果Mex比x大,那么就删除那个和x相同的元素…
A. Mahmoud and Ehab and the MEX 题目链接:http://codeforces.com/contest/862/problem/A 题目意思:现在一个数列中有n个数,每个数小于等于100,现在要让这个数列的met=k,意思是如果从1-100中第一个未出现的数字为met. 题目思路:在[0,k)区间内所有在数列中不存在的数的数量+check(k),check()表示判断k是否存在,如果存在返回1,不存在返回0: 代码: //Author: xiaowuga #incl…
D. Mahmoud and a Dictionary 题目连接: http://codeforces.com/contest/766/problem/D Description Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean t…
地址:http://codeforces.com/contest/766/problem/D 题目: D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mahmoud wants to write a new dictionary that contains n words…
E. Mahmoud and a xor trip 题目连接: http://codeforces.com/contest/766/problem/E Description Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you can reach any city from an…
A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Description While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab ch…