This page is still under construction.

Parts of this page are still being built. What you see may change.

Decimal to Fraction

Time limit2sMemory limit256 MB

Summary
Convert a decimal with an optional parenthesized repeating part into its irreducible numerator/denominator form.
Level

Medium4 of 10

Topics
Math, Number theory, String
Solved
No attempts yet

Problem

In Dec World every rational number is written as a decimal, and in Frac World every rational number is written as a fraction. The two countries fought over this for a long time, then made peace and agreed to respect each other's notation.

The trouble is that Dec World uses so many decimals that rewriting them as Frac World fractions one by one is hard. After a long discussion the two countries came to you, the great scientist, for help.

Dec World marks a repeating decimal by wrapping the repeating part in parentheses. For example, 0.444... is written as 0.(4). Frac World writes a fraction so that the numerator and the denominator are coprime.

Input

The first line contains one decimal used in Dec World. Its length is at most 10 and its value is not negative.

The number starts with an integer part of one or more digits, and a decimal point, a non-repeating fractional part and a repeating part wrapped in parentheses may follow, in that order. The decimal point and the fractional part may be absent, and the repeating part may be absent. If the decimal point is present, at least one of the non-repeating part and the repeating part is present.

Output

Print on the first line the irreducible fraction equal to the given number, in the form numerator/denominator.

The denominator is always positive, and it is 1 when the value is an integer. For example, print 10/1 when the value is 10.

Examples4

  1. Example 1

    Input
    2015
    
    Expected output
    2015/1
    
  2. Example 2

    Input
    0.(4)
    
    Expected output
    4/9
    
  3. Example 3

    Input
    3.(142857)
    
    Expected output
    22/7
    
  4. Example 4

    Input
    9.(9)
    
    Expected output
    10/1