Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
How many integers from 1 to 64 inclusive are either a power of two or have exactly two 1-bits in binary?
- A. 22
- B. 23
- C. 7
- D. 14
Correct answer: A. 22
Powers of two up to 64 number 7, and the numbers up to 64 with exactly two 1-bits number 15; the two sets are disjoint, so the union has 22 elements.
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 longest palindromic subsequence of "bbbab"?
- Trains arrive at times 2, 4, 4, 6, 8 and depart at 3, 5, 7, 6, 9 (a departure at the same time as an arrival frees its platform first)…
- What is the sum of the positive divisors of 60 that are at most 10?
- In how many ways can a product of four matrices A B C D be fully parenthesised (by choosing the order of multiplication)?
- For the histogram [2, 1, 2], each bar i has a maximal rectangle width wi: the number of consecutive bars around i (including i) that are…
- How many distinct value pairs (x, y) with x < y satisfy x + y = 6 among the values in [1, 2, 3, 4, 5, 5, 1]?