#P2260. Double Remainder Product Sum
Double Remainder Product Sum
Double Remainder Product Sum
Given two positive integers n and m, compute the sum:
$$ S = \sum_{i=1}^{n} \sum_{j=1}^{m} (n \bmod i) \times (m \bmod j) \quad \text{for } i \neq j, $$
and output the result modulo 19940417.
Note: The summation is taken over all pairs \((i, j)\) with \(1 \le i \le n\) and \(1 \le j \le m\) such that \(i \neq j\).
inputFormat
The input consists of two integers n and m separated by spaces or newlines.
outputFormat
Output a single integer representing the computed value of \(S \bmod 19940417\).
sample
2 2
0