Data Structures & AlgorithmsHardCodeforces Div2 D · ICPC regional
How many subsets (chosen by position, the empty subset included) of [6, 1, 3, 5, 2] have a bitwise XOR equal to 4?
- A. 4
- B. 3
- C. 32
- D. 5
Correct answer: A. 4
Enumerate or DP over prefix XOR values: for each element, the set of achievable XORs doubles with the new element either included or not. The count is over subsets, so the empty subset counts when k = 0 and not otherwise.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the length of the shortest contiguous subarray of [2, -1, 2, 3, -4, 5, 1] whose sum is at least 6? Negative numbers are present…
- A sorted array of distinct values was rotated some number of times. Which technique finds the minimum element in O(log n) time, and why…
- In one operation you may increase any single element by 1. What is the minimum total number of operations needed to make the array [1, 1…
- Choose two NON-OVERLAPPING non-empty contiguous subarrays of [4, -1, 2, 6, -3, 5, -2] (the first must end before the second starts) and…
- In how many ways can a 2 × 9 board be tiled exactly with 2 × 1 dominoes (placed vertically) and 2 × 2 squares, with no overlaps and no…
- How many integers x with 1 ≤ x ≤ 1000 are perfect squares or perfect cubes (or both)?