Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
How many ordered pairs (x, y) with 1 <= x, y <= 10 satisfy gcd(x, y) = 1?
- A. 63
- B. 31
- C. 65
- D. 90
Correct answer: A. 63
Ordered pairs count (x, y) and (y, x) separately, so the value is about 6/pi^2 * 100 but exact by counting. Halving the count treats the ordered pairs as unordered, which is the usual slip.
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 elements of [12, 19, 40, 7, 31, 22, 13, 8] have a decimal digit sum divisible by 4?
- How many perfect squares lie in the range [50, 250] inclusive?
- How many contiguous subarrays of [6, 10, 15, 4] have gcd exactly 1?
- A linked list holds 1..8 in order. Reverse the first group of 2 nodes, keep the next group of 2 as is, reverse the next, and so on. What…
- Exactly how many permutations of 1..5 can be sorted by a single stack (push and pop operations, output must be 1, 2, 3, 4, 5)?
- A queue holds 3, 1, 4, 2, 5 from front to back. You repeatedly look at the front element: if it is the next value needed (starting with…