← All problemsSign in

Permutations

CodeChefRating 2976Open on judge ↗

You are given a set $S$, which is a subset of $\{1, 2, \ldots, N\}$. Consider a permutation $P_1, P_2, \ldots, P_N$ of the integers $1$ through $N$. The cost of this permutation is the number of indices $i \gt 1$ such that $P_i$ is divisible by $P_{i-1}$ and $\frac{P_i}{P_{i-1}} \in S$. For each $k$ between $0$ and $N-1$ (inclusive), find the number of permutations with cost $k$. Since these

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start