Sum of range distinct queries
You are given an array $A$ of size $N$, and an integer $K$. Let $f(l,r)$ be defined as the number of **distinct** elements in the subarray $A[l, r]$. Find the sum of $f^K$ over all subarrays. More formally, find $\sum_{l=1}^{n} \sum_{r=l}^{n} f^K(l,r)$. Since this value can be huge, print it modulo $998244353$. Note: - $f^K(l,r)$ denotes the product of $K$ copies of $f(l,r)$. - $A[l, r]$ den
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