A7883 | Phone Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains nonempty sequence consisting of digits from $0$ to $9$ — Masha's phone number. The sequence length does not exceed $50$ .
输出格式
Output the single number — the number of phone numbers Masha will dial.
输入输出样例
输入 #1
12345
输出 #1
48
输入 #2
09
输出 #2
15
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted