8 人解决,12 人已尝试。
8 份提交通过,共有 20 份提交。
6.4 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Consider the following bijection between words from the alphabet {a,b} and the the set of non-negative integers, N:
f: {a,b}* -> N
e -> 0 (empty word)
a -> 1
b -> 2
aa -> 3
ba -> 4
ab -> 5
bb -> 6
aaa -> 7
baa -> 8
Your task is to write a program that can transform words from alphabet {a,b} with maximum size less than 30 into the corresponding integers and also transform integers into the corresponding words, according to the mapping defined above.
The input consists of a sequence of lines and each line can either be a word from the alphabet or an integer. It is guaranteed that the given integer corresponds to a word of maximum size less than 30. All the words in the input are non-empty and the integers are greater than zero.
For each line of input, a word or an integer, you should output also in separate lines the corresponding integer or word according to the mapping defined above.
b 5 aaa 18
2 ab 7 bbaa
8 人解决,12 人已尝试。
8 份提交通过,共有 20 份提交。
6.4 EMB 奖励。