Data Structures & AlgorithmsHardCodeforces Div 2 C · ICPC regional
From the values [3, 5, 6, 7, 10], choose any non-empty subset and XOR its elements together. What is the largest value that can be obtained?
- A. 15
- B. 13
- C. 16
- D. 10
Correct answer: A. 15
The maximum XOR over subsets is found with a linear basis (Gaussian elimination over GF(2)) or by enumerating all 31 non-empty subsets. Taking the largest value alone or the sum modulo 16 answers a different question.
More Coding Interview Problems questions
- Four groups are G1 = {1, 4}, G2 = {2, 9}, G3 = {3, 7} and G4 = {5, 6}. Choosing exactly one element from each group, how many choices sum…
- Using each of the values 1, 2, 5, 9 and 20 at most once, which is the smallest positive integer that CANNOT be written as the sum of some…
- Half-open segments [1,4), [3,7), [6,10), [9,12), [2,5), [8,11) are given. Choose pairwise disjoint segments to maximise the total length…
- Closed intervals [0,3], [2,5], [4,8], [6,9], [8,12] are available. What is the minimum number of them needed so that every point of the…
- Closed intervals [1,6], [4,10], [5,5], [8,12], [2,3] are given. For the query points 5, 9 and 1, count how many intervals contain each…
- Piles of bananas [3, 6, 7, 11] must be eaten within H = 8 hours. Each hour you eat up to k bananas from one pile (a pile is finished in…