← 返回 tesla 的题目列表Decode Ways
类型:online_judge
Problem: Decode Ways
A message containing letters A-Z can be encoded into numbers as follows:
'A' -> "1"
'B' -> "2"
...
'Z' -> "26"
Given a string s containing only digits, return the number of ways to decode it.
Notes:
Digit '0' cannot be decoded by itself.
0 is valid only as part of "10" or "20".
If there is no valid decoding, return 0.
Input Format
One line containing a digit string s.
Output Format
Print one integer: the number of decoding ways.
Constraints
1 <= len(s) <= 100
s contains only characters '0' to '9'
Example
Input:
226
Output:
3
Explanation: 226 can be decoded as "BZ", "VF", or "BBF".
Example
Input
12
Output
2