P1372 Graduation Season Again I
Background
"Ding-ling-ling-ling." With the ringing of the final bell of the Gaokao, three years of youth are frozen in this moment. The joy of graduation cannot outweigh the sorrow of parting; while looking forward to the future, we still do not forget the songs of the past. Over $1000$ days and nights of laughter and tears are condensed into the graduation party. We believe this must be one of the most unforgettable moments in a lifetime.
Description
To make the graduation party better, the teacher wants to select $k$ students with the highest compatibility to participate in the rehearsal. But how to choose? The teacher lists all student numbers $1, 2, \ldots, n$ and believes that the compatibility level of $k$ students is their greatest common divisor (this is not superstition~). This is difficult for him, so please help!
PS: The greatest common divisor of a single number is the number itself.
Input Format
Two space-separated positive integers $n$ and $k$.
Output Format
A single integer: the maximum compatibility value.
Explanation/Hint
For $20\%$ of the testdata, $k \le 2$, $n \le 10^3$.
For another $30\%$ of the testdata, $k \le 10$, $n \le 100$.
For $100\%$ of the testdata, $k \le 10^9$, $n \le 10^9$, $n \ge k \ge 1$ (a "Shenben" school, many students).
Translated by ChatGPT 5