K - X Makes the Difference
CodeChefOpen on judge ↗
You are given an integer $n$. We call a positive integer $x$ *good* with respect to $n$, if there exists a permutation$^\dagger$ $p$ of the integers $\{1, 2, \ldots, n\}$ such that $$ |p_i - p_{n + 1 - i}| = x $$ for *all* $1 \le i \le n$. Here, $|d|$ denotes the absolute value of $d$. For example, $|1| = 1, |-2| = 2, |0| = 0$. Count the number of integers that are *good* with respect to the g
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