Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
What is the sum of all integers x in [1, 50] that are divisible by 4 or by 6?
- A. 409
- B. 410
- C. 412
- D. 408
Correct answer: D. 408
Use inclusion-exclusion on the sums: multiples of 4 plus multiples of 6 minus multiples of 12 (counted once).
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 positive divisors of 360 are odd?
- What is the largest n such that 1 + 2 + ... + n does not exceed 1000?
- How many primes p with 2 <= p <= 30 satisfy p ≡ 1 (mod 4)?
- How many integers x in [1, 100] satisfy x ≡ 3 (mod 4) and x ≡ 7 (mod 10)?
- What is 2^100 mod 9?
- A 12-hour clock shows 1:30 p.m. Ignoring seconds, what hour (1 to 12) is shown 500 minutes later?