Data Structures & AlgorithmsVery hardCAT · Codeforces Div2 B
How many integers x in [1, 1000] have digit sum equal to 9 and are divisible by 9?
- A. 55
- B. 56
- C. 57
- D. 59
Correct answer: A. 55
A number's digit sum is congruent to it modulo 9, so digit sum 9 is equivalent to divisibility by 9; the two conditions coincide.
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
- There are 7 people in a circle numbered 1 to 7. Starting at person 1 and counting 1, 2, 3, ..., every 3rd person is removed until one…
- How many contiguous subarrays [i..j] of [2, 5, 3, 5, 1] have a[i] equal to the maximum of that subarray (ties allowed)?
- Three jobs given as (processing time, weight) are (3, 2), (1, 4), (2, 1). They run one at a time from time 0. What is the minimum possible…
- How many integers from 1 to 200 inclusive have exactly 3 positive divisors?
- How many contiguous subarrays of [3, 1, 2, 5, 4, 6] consist of distinct consecutive integers (in any order)?
- What is the length of the shortest contiguous subarray of [1, 2, 3, 1, 2, 4, 3] that contains every distinct value present in the array?