QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 256 MB Total points: 10

#204. A + B

Statistics

不要相信你在电视上看到的一切!Bajtuś最近在换台时看到了这样一幕:有人错误地进行了竖式加法(见左图):

这完全扭曲了他对数学的理解,这个可怜的孩子现在对两个数的竖式加法产生了困惑。Bajtuś将两个数上下对齐(右对齐),然后在每一位上将两个数字相加(例如 $8 + 8 = 16$),并将它们的和直接写在下方对应的位置上。如果某一位上只有一个数字(因为一个数比另一个数短),Bajtuś就直接把这个数字抄到结果中。当然,他使用的是十进制。在右上角,你可以看到用这种方法计算的另外两个例子。

有一天,Bajtuś用上述方法“加”了两个非负整数 $a$ 和 $b$,得到了“和” $n$。然而,他不小心把果汁洒在了写有计算过程的纸上,导致数字 $a$ 和 $b$ 变得无法辨认!他现在想知道,有多少对非负整数有序对 $(a, b)$ 可能写在纸上。请帮他确定这个数量!

输入格式

输入的第一行也是唯一一行包含一个整数 $n$ ($1 \le n < 10^{18}$)。

输出格式

输出一个整数,表示经过Bajtuś的“加法”后结果为 $n$ 的非负整数有序对 $(a, b)$ 的数量。

样例

输入 1

112

输出 1

50

说明

在Bajtuś的纸上,可能是以下50对数字中的任意一对:$(0, 112), (1, 111), (2, 110), (3, 19), (4, 18), (5, 17), (6, 16), (7, 15), (8, 14), (9, 13), (10, 102), (11, 101), (12, 100), (13, 9), (14, 8), (15, 7), (16, 6), (17, 5), (18, 4), (19, 3), (20, 92), (21, 91), (22, 90), (30, 82), (31, 81), (32, 80), (40, 72), (41, 71), (42, 70), (50, 62), (51, 61), (52, 60), (60, 52), (61, 51), (62, 50), (70, 42), (71, 41), (72, 40), (80, 32), (81, 31), (82, 30), (90, 22), (91, 21), (92, 20), (100, 12), (101, 11), (102, 10), (110, 2), (111, 1)$ 以及 $(112, 0)$。

请注意,例如 $(3, 19)$ 和 $(19, 3)$ 是分别计算的,因为我们关心的是有序对。

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.