Data Structures & AlgorithmsVery hardCAT · Codeforces Div2 B
How many integers x with 1 <= x <= 600 are divisible by 4 or 6 but not by 12?
- A. 151
- B. 147
- C. 155
- D. 150
Correct answer: D. 150
Use inclusion-exclusion: multiples of 4 plus multiples of 6 minus multiples of 12 gives multiples of 4 or 6; then remove multiples of 12 explicitly.
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 contiguous subarrays of [6, 12, 18, 8, 4] have gcd exactly equal to 2?
- What is the least common multiple of the integers 2 through 20, reduced modulo 1000000007?
- How many contiguous subarrays of [2, 5, 3, 4, 10] have a product divisible by 10?
- How many integers from 1 to 1000 have digit sum exactly 10 and are odd?
- How many ordered pairs (a, b) with 1 <= a, b <= 6 satisfy a b ≡ 1 (mod 7)?
- How many contiguous subarrays of [1, 1, 2, 1, 1] have all elements of the same parity?