C - Counting is Fun
CodeChefOpen on judge ↗
You are given an integer $S$. Let $f(N)$ denote the sum of **inversion numbers**$^{\dagger}$ for all arrays $A$ with positive integers, and of length $N$ with sum $S$. Formally, $f(N)$ is the sum of **inversion numbers** for arrays satisfying the following conditions: - $|A| = N$ - $1 \le A_i \le S$ and $A_i$ are integers - $\sum_{i = 1}^{N} A_i = S$ Find the values of $f(1), f(2), \ldots,
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