Data Structures & AlgorithmsVery hardCAT · Codeforces Div2 B
How many integers x in the range 1 to 1000 are divisible by 3 and have a digit sum divisible by 7?
- A. 47
- B. 28
- C. 46
- D. 4
Correct answer: B. 28
Scan 1 to 1000, keep multiples of 3 and test the actual digit sum mod 7: 28 qualify. Testing x mod 7 instead of the digit sum gives 47 (multiples of 21), assuming the two tests are independent gives 46, and demanding that x also be a multiple of 7 gives 4.
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 [3, 4, 1, 2, 5, 6] have a sum divisible by 5?
- How many pairs i < j with 1 <= i, j <= 12 have i times j divisible by 12?
- What is the value of the sum of floor(20 / i) for i = 1 to 20?
- A bubble sort performs left-to-right passes, swapping adjacent elements that are out of order, and stops after the first pass in which no…
- Six people stand in a circle numbered 1 to 6. Starting from person 1, every 4th person (counting the start as 1) is removed until one…
- How many contiguous subarrays of [1, 3, 2, 4, 6, 5] have (maximum minus minimum) at most 2?