Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
How many pairs a < b with 1 <= a < b <= 12 satisfy gcd(a, b) = b - a?
- A. 24
- B. 25
- C. 23
- D. 27
Correct answer: C. 23
gcd(a, b) divides b - a, so the condition means gcd(a, b) equals the gap itself, which forces the gap to divide a. Enumerate the pairs whose gap divides a.
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 integers n in [1, 60] satisfy n^2 - n divisible by 6?
- What is the length of the longest contiguous subarray of [4, 3, 2, 6, 1, 5] whose sum is at most 10?
- How many times does the pattern aab occur in the string aabaabaab, counting overlapping matches?
- How many pairs (a, b) with 1 <= a <= b <= 12 satisfy lcm(a, b) > 36?
- Treat [4, -1, 5, -6, 3] as circular. Over all contiguous circular windows of length 1 to 5, what is the maximum window sum?
- How many integers from 1 to 1000 inclusive have a decimal digit sum equal to 10?