#P5535. 【XR-3】小道消息

    ID: 4492 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学O2优化素数判断,质数,筛法最大公约数,gcd

【XR-3】小道消息

Description

Xiao X wants to study how fast a rumor spreads, so he did a social experiment.

There are nn people. The number on person ii's clothes is i+1i+1. Xiao X found a rule: if a person whose clothing number is ii learns a piece of information on some day, then on the next day he will tell this information to every person whose clothing number is jj such that gcd(i,j)=1\gcd(i,j)=1 (that is, the greatest common divisor of ii and jj is 11). On day 00, Xiao X tells a rumor to the kk-th person. Xiao X wants to know on which day everyone will know this rumor.

It can be proven that such a day when everyone knows the rumor must exist.

Hint: You may need the following theorem — Bertrand–Chebyshev theorem.

Input Format

One line with 22 positive integers n,kn,k.

Constraints:

  • 2n10142 \le n \le 10^{14}.
  • 1kn1 \le k \le n.

Output Format

One line with one positive integer, the answer.

3 1

2

6 4

1

Hint

Explanation for Sample 11

The clothing numbers of the 33 people are 2 3 4.

On day 00, Xiao X tells a rumor to person 11, whose clothing number is 22.

On day 11, person 11 will tell person 22 because gcd(2,3)=1\gcd(2,3)=1, but he will not tell person 33 because gcd(2,4)=21\gcd(2,4)=2 \ne 1.

On day 22, person 22 will tell person 33 because gcd(3,4)=1\gcd(3,4)=1. Now everyone knows the rumor, so the answer is 22.

Translated by ChatGPT 5