AtCoder Grand Contest 047
翻译中…
Problem Statement
翻译中…
Let’s take a prime $P = 200\,003$. You are given $N$ integers $A_1, A_2, \ldots, A_N$. Find the sum of $((A_i \cdot A_j) \bmod P)$ over all $N \cdot (N-1) / 2$ unordered pairs of elements ($i < j$).
翻译中…
Please note that the sum isn't computed modulo $P$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 200\,000$$0 \leq A_i < P = 200\,003$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format.
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
Print one integer — the sum over $((A_i \cdot A_j) \bmod P)$.
翻译中…
样例
Input #1
4
2019 0 2020 200002
Output #1
474287
The non-zero products are:
- $2019 \cdot 2020 \bmod P = 78320$
- $2019 \cdot 200002 \bmod P = 197984$
- $2020 \cdot 200002 \bmod P = 197983$
So the answer is $0 + 78320 + 197984 + 0 + 0 + 197983 = 474287$.
Input #2
5
1 1 2 2 100000
Output #2
600013
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。