Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
How many integers from 1 to 1000 inclusive are divisible by 8 and have an even number of 1-bits in binary?
- A. 63
- B. 125
- C. 500
- D. 62
Correct answer: D. 62
Enumerate multiples of 8 (125 of them) and test the parity of their popcount. Multiplying the count by a probability of one half is only an estimate.
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
- Repeatedly merge two values into their sum at cost equal to that sum, starting from [1, 2, 3, 4]. What is the minimum total cost?
- How many integers from 1 to 100 inclusive have an odd number of positive divisors?
- What is the length of the longest common substring (contiguous) of "abcdef" and "zcdemf"?
- When converting the infix expression "(a+b)(c-d)/e" to postfix, how many operator symbols appear in the postfix output?
- What is the sum of all odd positive divisors of 180?
- How many distinct sums arise from the length-3 windows of [1, 1, 2, 2, 3, 3, 1]?