QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 64 MB Puntuación total: 140

#16414. PAROVI

Estadísticas

两个整数之间的距离定义为它们对应数位上数字差的绝对值之和。例如,数字 $4561$ 和 $3278$ 之间的距离为 $|4 - 3| + |5 - 2| + |6 - 7| + |1 - 8| = 12$。如果其中一个数字的位数较少,我们用前导零将其补齐。因此,数字 $32$ 和 $5678$ 之间的距离为 $|0 - 5| + |0 - 6| + |3 - 7| + |2 - 8| = 21$。

给定两个整数 $A$ 和 $B$。计算区间 $[A, B]$ 内所有有序数对之间的距离之和!

输入格式

输入的第一行且仅一行包含两个整数 $A, B$ ($1 \le A \le B \le 10^{50000}$)。

输出格式

输出的第一行且仅一行应包含题目所求的答案。由于答案可能非常大,请将答案对 $1\,000\,000\,007$ 取模后输出。

数据范围

  • 在占总分 20% 的测试数据中,$A$ 和 $B$ 不超过 $10000$。
  • 在占总分 40% 的测试数据中,$A$ 和 $B$ 不超过 $10^{100}$。

样例

输入格式 1

1 5

输出格式 1

40

输入格式 2

288 291

输出格式 2

76

输入格式 3

1000000 10000000

输出格式 3

581093400

说明

第二个样例的解释:

这些数对之间的距离分别为:

  • $(288, 289) = 1$
  • $(288, 290) = 9$
  • $(288, 291) = 8$
  • $(289, 290) = 10$
  • $(289, 291) = 9$
  • $(290, 291) = 1$

由于是有序数对,每种组合都会被计算两次,因此总和为 $2 \times (1 + 9 + 8 + 10 + 9 + 1) = 76$。

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.