Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
What is the total number of 1-bits in the binary representations of all integers from 0 to 31 inclusive?
- A. 80
- B. 81
- C. 75
- D. 82
Correct answer: A. 80
Each bit position is set in exactly half of the 32 numbers, so the total is 5 times 16 = 80. The bitwise formula gives the same answer.
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
- How many integers from 1 to 100 inclusive are perfect squares or perfect cubes?
- What is the minimum number of single-character replacements needed to make "abcdba" a palindrome?
- How many well-formed strings of 3 pairs of parentheses (length 6) exist?
- On a line with cells 1 to 10, a lamp at position p lights cells p-2 to p+2. Lamps are placed at positions 1, 4, 6, 9. Do they light every…
- The histogram heights [1, 3, 3, 2, 3] describe bars of width 1. What is the area of the largest rectangle that fits under the histogram?
- How many integers from 1 to 50 inclusive have exactly two 1-bits in binary and are even?