← All problemsSign in

Sum Over All Arrays

CodeChefRating 3033Open on judge ↗

Consider an array $B$ of length $M$. The *beauty* of $B$ is defined as $\sum_{i=1}^{M} |B_i-B_{M+1-i}|$. The **score** of $B$ is the **maximum** *beauty* over **all** permutations of $B$. You are given positive integers $N$ and $X$. Find the sum of **scores** of all arrays $A$ of length $N$, such that $1 \leq A_i \leq X$. Since the sum might be large, please print it modulo $998244353$.

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