Official

A - Simple Math Editorial by evima


We have:

\[\sum_{a=1}^{A} \sum_{b=1}^{B} \sum_{c=1}^{C} abc\]

\[= \sum_{a=1}^{A} a \sum_{b=1}^{B} b \sum_{c=1}^{C} c\]

\[= \frac{A(A+1)}{2} \frac{B(B+1)}{2} \frac{C(C+1)}{2}\]

We just need to compute it. Sample Implementation in Python3 follows:

A, B, C = map(int, input().split())
sum = A*(A+1)//2 * B*(B+1)//2 * C*(C+1)//2
print(sum % 998244353)

By the way, we can also get this formula by entering Sum[ Sum[ Sum[ abc, {c, 1, C}], {b, 1, B}], {a, 1, A}] in https://www.wolframalpha.com/.

posted:
last update: