#P1530. [USACO2.4] 分数化小数 Fractions to Decimals

[USACO2.4] 分数化小数 Fractions to Decimals

Description

Write a program that, given a fraction of the form ND\dfrac{N}{D}, outputs its decimal representation. If the decimal has a repeating cycle, enclose the cycle in a pair of parentheses.

For example, 13=0.33333333\dfrac{1}{3}=0.33333333\ldots is written as 0.(3)0.(3), 41333=0.123123123\dfrac{41}{333}= 0.123123123\ldots is written as 0.(123)0.(123), and an integer xx is written as x.0x.0.

Input Format

The input contains two integers NN and DD (1N,D1051 \leq N, D \leq 10^5).

Output Format

Output the decimal representation computed according to the rules above. If the length of the result exceeds 7676, print 7676 characters per line.

45 56
0.803(571428)

Hint

Translated from NOCOW. USACO 2.4

Translated by ChatGPT 5