← 返回 google 的题目列表Count Spellings of a Word Using Chemical Element Symbols
类型:online_judge
Given a target word word consisting only of English letters, count the number of distinct ways to spell the entire word using chemical element symbols.
Use all standard symbols from the periodic table. Each symbol has one or two letters. Matching is case-insensitive, but each symbol must match a contiguous substring of the word. Different segmentations into element symbols count as different spellings.
For example, Physics has four spellings:
P - H - Y - Si - C - S
P - H - Y - Si - Cs
P - H - Y - S - I - C - S
P - H - Y - S - I - Cs
Return the total number of spellings. Return 0 if the word cannot be spelled.
Input Format
One line containing word.
Output Format
Print one integer: the total number of valid spellings.
Constraints
1 <= len(word) <= 2000
word contains only English letters.
The result fits in a Python integer.
Example
Input
Physics
Output
4