Sequinary Numerals
시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC Greater New York 2021BOJ 24739
문제
A sequinary numeral is a sequence of digits:
dndn-2...d1d0
where dn is 1 or 2 and the others are 0, 1, or 2.
It represents the rational number:
d0 + d1 * (3/2) + d2 * (3/2)2 + ... + dn * (3/2)n
Write a program which takes a sequinary numeral as input and returns the number it represents as a proper fraction.
입력
The single line of input contains a sequinary numeral of no more than 32 digits.
출력
Output consists of a single line.
If the result is an integer, the output is the decimal integer. Otherwise, the output is N a single space and K/M where N, K and M are decimal integers where K < M and K/M is in lowest terms (GCD(K, M) = 1).
예제
예제 1
입력
2101
출력
10
예제 2
입력
201
출력
5 1/2
코드를 제출하려면 로그인하세요.