CF44H.Phone Number

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy.

The phone number is divined like that. First one needs to write down one's own phone numbers. For example, let's suppose that Masha's phone number is 12345. After that one should write her favorite digit from 0 to 9 under the first digit of her number. That will be the first digit of the needed number. For example, Masha's favorite digit is 9. The second digit is determined as a half sum of the second digit of Masha's number and the already written down first digit from her beloved one's number. In this case the arithmetic average equals to (2 + 9) / 2 = 5.5. Masha can round the number up or down, depending on her wishes. For example, she chooses the digit 5. Having written down the resulting digit under the second digit of her number, Masha moves to finding the third digit in the same way, i.e. finding the half sum the the third digit of her number and the second digit of the new number. The result is (5 + 3) / 2 = 4. In this case the answer is unique. Thus, every i-th digit is determined as an arithmetic average of the i-th digit of Masha's number and the i - 1-th digit of her true love's number. If needed, the digit can be rounded up or down. For example, Masha can get:

12345

95444

Unfortunately, when Masha tried dialing the number, she got disappointed: as it turned out, the number was unavailable or outside the coverage area. But Masha won't give up. Perhaps, she rounded to a wrong digit or chose the first digit badly. That's why she keeps finding more and more new numbers and calling them. Count the number of numbers Masha calls. Masha calls all the possible numbers that can be found by the described means of arithmancy, except for, perhaps, her own one.

唉,找到自己的真命天子并不容易。玛莎至今仍未成功。她的朋友达莎告诉玛莎一种通过“算术占卜术”(arithmancy)来推算自己白马王子电话号码的方法。

电话号码是这样推算出来的:首先,需要写下自己的电话号码。例如,假设玛莎的电话号码是 12345。接着,在她自己号码的第一位数字下方写上她最钟爱的、从 0 到 9 中的一个数字——这将成为目标号码的第一位数字。例如,玛莎最钟爱的数字是 9。第二位数字则由她自己号码的第二位数字与已写出的“心上人号码”的第一位数字之和的一半(即算术平均数)确定。本例中,该平均值为 (2+9)/2=5.5(2 + 9) / 2 = 5.5。玛莎可根据自己的意愿将该数向上或向下取整(即四舍五入至最近的整数,若为 .5 则可任选向上或向下)。例如,她选择了数字 5。将所得数字写在自己号码第二位数字下方后,玛莎以同样方式继续求第三位数字:即她自己号码的第三位数字与新号码第二位数字之和的一半。结果为 (3+5)/2=4(3 + 5) / 2 = 4;此时结果唯一。因此,目标号码的第 ii 位数字定义为:玛莎自己号码的第 ii 位数字与她心上人号码的第 i−1i-1 位数字之和的算术平均数;必要时可向上或向下取整。例如,玛莎可能得到如下结果:

12345  
95444

不幸的是,当玛莎尝试拨打这个号码时,却大失所望:原来该号码无法接通,或不在信号覆盖范围内。但玛莎不会放弃!也许她某一位数字取整错误,或一开始便选错了首位数字。因此,她不断生成越来越多的新号码并逐一拨打。请计算玛莎总共会拨打多少个不同的号码。玛莎会拨打所有可通过上述算术占卜术生成的可能号码(她自己的号码除外,即若生成的号码恰好等于她自己的号码,则不拨打)。

输入格式

The first line contains nonempty sequence consisting of digits from 0 to 9 — Masha's phone number. The sequence length does not exceed 50.

第一行包含一个非空的数字序列,由 0 到 9 的数字组成——即玛莎的电话号码。该序列的长度不超过 50。

输出格式

Output the single number — the number of phone numbers Masha will dial.

输出一个数字——玛莎将拨打的电话号码数量。

输入输出样例

  • 输入#1

    12345

    输出#1

    48
  • 输入#2

    09

    输出#2

    15

输入解题思路,AI测评打分。不知道怎么写?

首页