#P1530. Decimal Expansion with Repeating Decimals
Decimal Expansion with Repeating Decimals
Decimal Expansion with Repeating Decimals
Write a program that takes as input a fraction in the form \(\frac{N}{D}\) and outputs its decimal representation. If the decimal has a repeating cycle, enclose the repeating sequence in parentheses.
For example, \(\frac{1}{3}=0.33333333\ldots\) should be represented as 0.(3)
, \(\frac{41}{333}=0.123123123\ldots\) as 0.(123)
, and an integer x should be output as x.0
.
inputFormat
The input consists of a single line containing a fraction in the form \(N/D\), where N and D are integers and D is non-zero.
outputFormat
Output the decimal representation of the fraction. If the fraction results in a repeating decimal, enclose the repeating portion in parentheses. If the fraction is an integer, append ".0".
sample
1/3
0.(3)