#P1372. Maximize the Synergy Level
Maximize the Synergy Level
Maximize the Synergy Level
To make the graduation party a success, the teacher wants to select k students whose synergy level is the highest. The teacher believes that the synergy level of any chosen group of k students, whose numbers are taken from the set {1, 2, ..., n}, is equal to the greatest common divisor (gcd) of their numbers.
Your task is to help the teacher choose the group so that their gcd is maximized. Notice that the gcd of a single number is the number itself. In general, if you choose k numbers that are all multiples of d, then their gcd is at least d. Hence, we want to find the maximum integer d such that there are at least k multiples of d in the range [1, n].
This condition can be written mathematically as:
\( \left\lfloor \frac{n}{d} \right\rfloor \ge k \)
It can be shown that the maximum possible gcd is given by:
\( d = \left\lfloor \frac{n}{k} \right\rfloor \)
Compute and output this value.
inputFormat
The input consists of a single line containing two integers n and k (1 ≤ k ≤ n), where n represents the total number of students and k represents the number of students to choose.
outputFormat
Output a single integer representing the maximum possible synergy level (i.e. the maximum gcd of the chosen k numbers).
sample
10 4
2