Perfect Permutation
An index $i$ in a permutation $P$ of length $N$ is said to be *good* if: - $P_i$ is divisible by $i$ You are given $2$ integers $N$ and $K$. You need to construct a permutation $P$ of length $N$ such that **exactly** $K$ indices in that permutation are good. If no such permutation exists, output $-1$. If multiple such permutations exist, output any. ### Input - The first line contains a single
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