QOJ.ac

QOJ

时间限制: 2 s 内存限制: 1024 MB 总分: 10

#17389. 加法 [C]

统计

Bajtek 正在学习列竖式加法。他将三个长度均为 $n$ 的数字上下排列。现在他想知道,有多少对 $(i, j)$(满足 $1 \le i \le j \le n$)使得这三个数字从第 $i$ 位到第 $j$ 位的片段构成一个正确的加法算式(即第三个数的片段等于前两个数片段之和)。所有数字均允许包含前导零。

输入格式

输入包含三行,每行一个整数(可能包含前导零)。这三个整数的长度均为 $n$ ($1 \le n \le 10^6$)。

输出格式

输出一个整数,表示有多少对 $(i, j)$ 构成了正确的加法算式。

样例

输入 1

037523
040834
978367

输出 1

4

说明

样例解释:正确的加法对包括 $(2, 2)$(因为 $3+4 = 7$)、$(2, 4)$(因为 $375+408 = 783$)、$(3, 4)$(因为 $75 + 8 = 83$)以及 $(6, 6)$(因为 $3 + 4 = 7$)。请注意,尽管 $(2, 2)$ 和 $(6, 6)$ 的片段内容相同,但我们仍将其视为两次不同的计数。我们不计算未对齐的片段之和,例如 $3 + 3 = 6$ 的情况。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download
#1358EditorialOpen题解Milmon2026-03-31 16:26:48View

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.