Code | Solution | Tests |
Transmitting and memorizing information is a task that requires different coding systems for the best use of the available space. A well known system is that one where a number is associated to a character sequence. It is considered that the words are made only of small characters of the English alphabet a,b,c, ..., z (26 characters). From all these words we consider only those whose letters are in lexigraphical order (each character is smaller than the next character).
The coding system works like this:
a 000000- 1
b 000000- 2
...
z 000000- 26
ab 00000- 27
...
az 00000- 51
bc 00000- 52
...
vwxzy00 - 83681
...
Task
Specify for a given word if it can be codified according to this coding system. For the affirmative case specify its code.
Input format
The input file COD.IN contains a word on each line.
Output format:
The output file COD.OUT will contain the code of the given word, or 0 if the word can not be codified.
Constraints
Examples:
COD.IN | COD.OUT |
bf | 55 |
COD.IN | COD.OUT |
aab | 0 |
COD.IN | COD.OUT |
vwxyz | 83681 |
Time limit: 2 seconds/test