CodeForces - 1230D(思维+位运算)】的更多相关文章

题目链接 题目大意 给你一个长为n(n<=1e5)的数组,让你求有多少对a[i]和a[j] (i!=j)满足a[i]&a[j]>a[i]^a[j] 题目思路 这些有关位运算的题目肯定是要把数字变成二进制的 在二进制中某一位的数只能是0或者1 0^0=0 0&0=0 0^1=1 0&1=0 1^0=1 1&0=0 1^1=0 1&1=0 这样你就会发现如果要&操做所获得的值更大,只有可能是最高位的1所处的位置相同 然后计算一下贡献即可 代码 #in…
C. XOR and OR time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a differen…
题意 https://vjudge.net/problem/CodeForces-1230D 要组建一个小组,要求小组中每个人都不比所有人强,当一个人懂得一个算法但是另一个不懂那么前者认为他比后者强.所以这个小组要满足一个人懂得算法必定有另一个人全懂.每个人的技能是不同的,要求出这个小组能组成的技能最大值. 思路 先遍历一遍,用map记录a[i](会的算法)的个数,出现次数大于等于2的a[i],是肯定可以放到小组里的,因为有人和他的懂的相同. 然后对出现次数小于2的人,和刚才确定的人的对比,如果…
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing…
题意:RT 题解: \(i\ mod \ k=0\),即所有事\(k\)的倍数的位置都要进行异或,根据异或的性质,我们知道如果相同的异或的数个数是偶数的话,得出的结果是\(0\),所以每次询问,我们判断需要进行异或的个数,如果不是奇数的话就不用求贡献,这儿还有个结论,如果我们原来有偶数的个数,然后进行一次异或操作后变成了奇数,那么这次操作得到的贡献就是\(v\),因为假设原来偶数位置的数是\(x\),那么我们对这些位置操作后得到\(x\)^\(v\),因为变成了奇数,所以我们在求总贡献的时候,多…
& -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 226732710 题意 t个测试样例,在每个样例中 数组有n个数,数字范围[ 0, 2k - 1] 使得数组每个数&后,结果=0,并且这n个数的和要尽量大 输出有多少个这样的数组 解析 数组每个数&后,结果=0  -->每一位至少一个0 数要尽量大  -->只要这一位可以 != 0, 就…
题目链接: Problem - B - Codeforces 题目 Example input 4 3 1 1 1 5 1 2 3 4 5 5 0 2 0 3 0 4 1 3 5 1 output 6 0 36 4 题意 给一串数,用这n个数排几种序列,使得 i=1~(n-1) 输出有几种序列满足情况 题解 附  : & -- 位运算之一,有0则0 不用怀疑,一堆数&完后,得到的数<=这堆数的任意一个数 因为每一位只要有一个数==0,这一位就=0,否则为1 记最后&完所有数的…
You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation saisbi is saved into a new string sn + …
题目传送门 /* 题意:给出无向无环图,每一个点的度数和相邻点的异或和(a^b^c^....) 图论/位运算:其实这题很简单.类似拓扑排序,先把度数为1的先入对,每一次少一个度数 关键在于更新异或和,精髓:a ^ b = c -> a ^ c = b, b ^ c = a; */ #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <…
A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can…