10245 - 分数化小数

写一个程序,输入一个形如N/D的分数(N是分子,D是分母),输出它的小数形式。 如果小数有循环节的话,把循环节放在一对圆括号中。例如, 1/3 = .33333333 写成0.(3) 41/333 = 0.123123123... 写成0.(123) 用xxx.0 成表示整数 典型的转化例子: 1/3 = 0.(3) 22/5 = 4.4 1/7 = 0.(142857) 2/2 = 1.0 3/8 = 0.375 45/56 = 0.803(571428)

输入

单独的一行包括被空格分开的 N和D, 1 <= N,D <= 100000。

输出

小数的表示方法上面说的很明白了,如果输出的长度超过76个字符,每行输出76个。

样例

输入

45 56

输出

0.803(571428)

提示

Fractions to Decimals

Write a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator and print the decimal representation. If the decimal representation has a repeating sequence of digits, indicate the sequence by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as 0.(3), and 41/333 = 0.123123123...is denoted as 0.(123). Use xxx.0 to denote an integer. Typical conversions are:

1/3 = 0.(3) 22/5 = 4.4 1/7 = 0.(142857) 2/2 = 1.0 3/8 = 0.375 45/56 = 0.803(571428)

PROGRAM NAME: fracdec INPUT FORMAT A single line with two space separated integers, N and D, 1 <= N,D <= 100000. SAMPLE INPUT (file fracdec.in) 45 56

OUTPUT FORMAT The decimal expansion, as detailed above. If the expansion exceeds 76 characters in length, print it on multiple lines with 76 characters per line. SAMPLE OUTPUT (file fracdec.out) 0.803(571428)

时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题