A - Coprime Pair 解説 by maspy


Given \(1 \leq L \leq R \leq 10^{18}\) and \(R - L \geq 17\), show that there exists \((x, y)\) satisfying the following conditions:

  • \(L \leq x \leq L + 16\)
  • \(R - 5 \leq y \leq R\)
  • \(\gcd(x, y) = 1\)

In particular, it can be proven that there exists \((x, y)\) such that \(\gcd(x, y) = 1\) and \(R - L - 21 \leq y - x \leq R - L\).


First, there exists \(y\) such that \(R - 5 \leq y \leq R\) and \(\gcd(y, 30) = 1\). This can be confirmed by examining each \(R \mod 30\).

Let the distinct prime factors of \(y\) in ascending order be \(p_1, p_2, \ldots, p_k\). The following properties hold:

  • \(k \leq 12\)
  • \(p_1 \geq 7\) (if \(k \geq 1\), and similarly for the following)
  • \(p_2 \geq 11\)
  • \(p_3 \geq 13\)
  • \(p_4 \geq 17\)
  • \(p_5 \geq 19\)
  • \(p_6 \geq 23\)
  • \(p_7 \geq 29\)
  • \(p_8 \geq 31\)
  • \(p_9 \geq 37\)
  • \(p_{10} \geq 41\)
  • \(p_{11} \geq 43\)
  • \(p_{12} \geq 47\)

This can be verified by greedily selecting prime factors other than \(2, 3, 5\) such that their product does not exceed \(10^{18}\).

Let \(n_i\) be the number of multiples of \(p_i\) in the range \(L, \ldots, L + 16\). Since \(n_i \leq \lceil 17 / p_i \rceil\), we have:

\[ \sum n_i \leq 3 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 16 \]

Thus, there exists a number in \(L, \ldots, L + 16\) that is not divisible by any of \(p_1, \ldots, p_k\). Let this number be \(x\). Then \((x, y)\) satisfies the conditions.

投稿日時:
最終更新: