Sequinary Numerals
InterviewTime limit1sMemory limit1024 MB
Convert a sequinary numeral (base 3/2 digits 0 to 2, leading digit 1 or 2) to its value, printed as an integer or as a mixed number with a reduced fraction.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
A sequinary numeral is a sequence of digits , where is 1 or 2 and every other digit is 0, 1, or 2. It represents the rational number . Write a program that takes a sequinary numeral and outputs the number it represents as a proper fraction.
Input
The single line of input contains a sequinary numeral of no more than 32 digits.
Output
Output a single line. If the result is an integer, output it as a decimal integer. Otherwise, output , a single space, and , where , , and are decimal integers, , and is in lowest terms ().