F - Minimum Divides Maximum
CodeChefOpen on judge ↗
You are given an integer $n$. You want to find a permutation$^\dagger$ $p$ of the integers $\{1, 2, \ldots, n\}$ such that the number of indices $i$ ($1 \le i \le n$) where $\max(p_1, p_2, \ldots, p_i)$ is divisible by $\min(p_1, p_2, \ldots, p_i)$ is as small as possible. Print the minimum value possible if you choose $p$ optimally. $^\dagger$ A permutation of the integers $\{1, 2, \ldots, n\}
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start