QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 64 MB مجموع النقاط: 120

#17088. 樱桃

الإحصائيات

Lana 住在一个虽小但快乐的村庄里。主街旁有一排樱桃树。Lana 用从 $1$ 开始的连续整数为这些树编了号。

经过深入研究,Lana 发现树的编号唯一决定了该树能产出的樱桃数量。

对于一棵树,考虑其编号中连续的相同数字组。对于每个数字组,将该数字乘以该组长度的平方。将所有组的这一结果相加,即得到该树产出的樱桃总数。

例如,在编号为 $77744007$ 的树中,数字组分别为 $777$、$44$、$00$ 和 $7$。其樱桃数量将为 $7 \cdot 3^2 + 4 \cdot 2^2 + 0 \cdot 2^2 + 7 \cdot 1^2 = 86$ 个单位。

采摘樱桃的季节到了,村民们同意采摘编号从 $A$ 到 $B$(含 $A$ 和 $B$)的所有樱桃树。编写一个程序,计算采摘的樱桃总数。

输入格式

输入包含两个整数 $A$ 和 $B$($1 \le A \le B \le 10^{15}$),分别表示要采摘的第一棵树和最后一棵树的编号。

输出格式

输出一个整数,表示将采摘的樱桃总单位数。

样例

输入样例 1

1 9

输出样例 1

45

输入样例 2

100 111

输出样例 2

68

输入样例 3

7774407 7774407

输出样例 3

86

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.