20250122

20250122 already? Time flies

Rehabilitation: 2063A. Minimal Coprime - 800

The problem description is too difficult for me to digest, but looking at the samples provided me with the solution.

[n, n + 1] (n >= 2) is coprime.

if n and n + 1 are not coprime, n = km, n + 1 = lm (l and m are integers, m >= 2), but (n + 1) - n = 1 = (l - k)m => contradiction.

[1, 1] is coprime because they share only one positive common divisor 1. (That makes [1, 2] not coprime).

When l >= 2, coprimes in [l, r] are [l, l + 1], [l + 1, l + 2], …, [r - 1, r], and the count is r - l.

When l == 1, coprimes in [l, r] are [1, 1], [2, 3],[3, 4], ...,[r - 1, r], and the count is alsor - l (r >= 2)` .

for _ in range(int(input())):
    l, r = map(int, input().split())
    if l == r == 1:
        print(1)
        continue
    print(r - l)

TODO:


index 20250121 20250123