Under construction

Still being built. Things may change

Sequinary Numerals

Interview

Time limit1sMemory limit1024 MB

Summary
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 dndn−1…d1d0d_n d_{n-1} \dots d_1 d_0, where dnd_n is 1 or 2 and every other digit is 0, 1, or 2. It represents the rational number d0+d1⋅32+d2⋅(32)2+⋯+dn⋅(32)nd_0 + d_1 \cdot \frac{3}{2} + d_2 \cdot \left(\frac{3}{2}\right)^2 + \dots + d_n \cdot \left(\frac{3}{2}\right)^n. 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 NN, a single space, and K/MK/M, where NN, KK, and MM are decimal integers, K<MK < M, and K/MK/M is in lowest terms (gcd⁡(K,M)=1\gcd(K, M) = 1).

Examples2

  1. Example 1

    Input
    2101
    
    Expected output
    10
    
  2. Example 2

    Input
    201
    
    Expected output
    5 1/2