#C3839. Fraction to Decimal Conversion

    ID: 47310 Type: Default 1000ms 256MiB

Fraction to Decimal Conversion

Fraction to Decimal Conversion

Given two integers, numerator and denominator, your task is to compute the decimal representation of the fraction (\frac{\text{numerator}}{\text{denominator}}). If the fractional part is repeating, enclose the repeating part in parentheses. For instance, (\frac{2}{3}) should be represented as 0.(6) and (\frac{22}{7}) should be represented as 3.(142857).

Note:

  • If the division yields an integer (i.e. no remainder), simply output the integer without any decimal point.
  • If the fraction is negative, the minus sign should appear at the beginning of the result.
Read the input from standard input (stdin) and print the result to standard output (stdout).

inputFormat

The input consists of a single line with two space-separated integers: the numerator and denominator.

outputFormat

Output the decimal representation of the fraction. If there is a repeating part in the decimal, enclose it in parentheses.## sample

1 2
0.5