#A. 小y的加法进位

    Type: Default 1000ms 256MiB

小y的加法进位

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

小y最近在复习竖式加法,这是大家从小最早学习运算时学的计算方法

  1 2 3
+ 4 5 6
--------
  5 7 9

而有时候计算过程中会碰到进位运算,比如 101+909101 + 909 需要进位 22

    1 0 1
+   9 0 9
----------
  1 0 1 0

甚至 1+9991 + 999 可能出现连续进位,一共进位 33

        1
+   9 9 9
----------
  1 0 0 0

现在小y突发奇想,他写下了 nn 个整数分别为 aia_i,他想知道,执行以下代码,运算结果会是多少?

int calc(int x, int y){
	return (x + y 过程中的进位次数)
}

for (int i = 1; i <= n; ++i){
	for (int j = i + 1; j <= n; ++j){
		ans += calc(a[i], a[j])
	}
}

cout << ans << endl;

输入格式

输入第一行包含一个整数 nn 表示数字个数

输入第二行包含 nn 个整数 a1,a2ana_1, a_2 \dots a_n,用空格隔开

输出格式

输出一行包含一个整数,表示上述代码运行的结果

数据范围

对于 10%10\% 的数据满足 n100n \leq 1000ai90 \le a_i \le 9

对于另外 20%20\% 的数据满足n1000n \leq 10000ai1090 \le a_i \le 10^9

对于另外 30%30\% 的数据,n100000n \leq 1000000ai10000 \le a_i \le 1000

对于 100%100\% 的数据,1n100000,0ai1091 \leq n \leq 100000, 0 \leq a_i \leq 10^9

样例输入1

3
1 9 99

样例输出1

5

样例解释1

1+91 + 9 进位了 111+991 + 99 进位了 229+999 + 99 进位了 22 次 所以一共进位了 55

样例输入2

20
28 3 42 32 26 24 98 25 96 22 91 89 55 18 10 50 24 45 31 76

样例输出2

156

数据结构——图(并查集)

Not Claimed
Status
Done
Problem
5
Open Since
2025-3-22 17:00
Deadline
2025-3-30 23:59
Extension
24 hour(s)