QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#3697. 进位

Estadísticas

frog 有 $n$ 个整数 $a_1, a_2, \dots, a_n$,她想要将它们两两相加。

不幸的是,frog 很害怕进位(carries)。她定义两个数 $x$ 和 $y$ 相加的“难度” $h(x, y)$ 为计算过程中产生的进位次数。例如,$h(1, 9) = 1, h(1, 99) = 2$。

请计算这 $n$ 个整数两两相加的总难度。换句话说,求 $$\sum_{1 \leq i < j \leq n} h(a_i, a_j)$$。

输入格式

输入包含多组测试数据。对于每组测试数据:

第一行包含一个整数 $n$ ($2 \leq n \leq 10^5$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \leq a_i \leq 10^9$)。

输出格式

对于每组测试数据,输出一个整数,表示总难度。

样例

样例输入 1

2
5 5
10
0 1 2 3 4 5 6 7 8 9

样例输出 1

1
20

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.