AtCoder Regular Contest 158
翻译中…
Problem Statement
翻译中…
For a positive integer $x$, let $f(x)$ denote the sum of its digits. For instance, $f(158) = 1 + 5 + 8 = 14$, $f(2023) = 2 + 0 + 2 + 3 = 7$, and $f(1) = 1$.
翻译中…
You are given a sequence of positive integers $A = (A_1, \ldots, A_N)$. Find $\sum_{i=1}^N\sum_{j=1}^N f(A_i + A_j)$.
翻译中…
Constraints
翻译中…
$1\leq N\leq 2\times 10^5$$1\leq A_i < 10^{15}$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
A_1 \ldots A_N
翻译中…
Output
翻译中…
Print $\sum_{i=1}^N\sum_{j=1}^N f(A_i + A_j)$.
翻译中…
样例
Input #1
2
53 28
Output #1
36
We have $\sum_{i=1}^N\sum_{j=1}^N f(A_i + A_j) = f(A_1+A_1)+f(A_1+A_2)+f(A_2+A_1)+f(A_2+A_2)=7+9+9+11=36$.
Input #2
1
999999999999999
Output #2
135
We have $\sum_{i=1}^N\sum_{j=1}^N f(A_i + A_j) = f(A_1+A_1) = 135$.
Input #3
5
123 456 789 101 112
Output #3
321
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。