103532: [Atcoder]ABC353 C - Sigma Problem
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:15
Solved:0
Description
Score: $300$ points
Problem Statement
For positive integers $x$ and $y$, define $f(x, y)$ as the remainder of $(x + y)$ divided by $10^8$.
You are given a sequence of positive integers $A = (A_1, \ldots, A_N)$ of length $N$. Find the value of the following expression:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j)$.Constraints
- $2 \leq N \leq 3\times 10^5$
- $1 \leq A_i < 10^8$
- All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $A_1$ $\ldots$ $A_N$
Output
Print the answer.
Sample Input 1
3 3 50000001 50000002
Sample Output 1
100000012
- $f(A_1,A_2)=50000004$
- $f(A_1,A_3)=50000005$
- $f(A_2,A_3)=3$
Thus, the answer is $f(A_1,A_2) + f(A_1,A_3) + f(A_2,A_3) = 100000012$.
Note that you are not asked to compute the remainder of the sum divided by $10^8$.
Sample Input 2
5 1 3 99999999 99999994 1000000
Sample Output 2
303999988
Input
Output
得分:300分
问题描述
对于正整数$x$和$y$,定义$f(x, y)$为$(x + y)$除以$10^8$的余数。
你被给定一个长度为$N$的正整数序列$A = (A_1, \ldots, A_N)$。请找到以下表达式的值:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j)$。限制条件
- $2 \leq N \leq 3\times 10^5$
- $1 \leq A_i < 10^8$
- 所有输入值都是整数。
输入
输入通过标准输入给出以下格式:
$N$ $A_1$ $\ldots$ $A_N$
输出
打印答案。
样例输入1
3 3 50000001 50000002
样例输出1
100000012
- $f(A_1,A_2)=50000004$
- $f(A_1,A_3)=50000005$
- $f(A_2,A_3)=3$
因此,答案是$f(A_1,A_2) + f(A_1,A_3) + f(A_2,A_3) = 100000012$。
注意,你不需要计算和除以$10^8$的余数。
样例输入2
5 1 3 99999999 99999994 1000000
样例输出2
303999988