문제2665--Be Rational

2665: Be Rational

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB
제출: 3  통과: 1
[제출] [채점기록] [묻고답하기]

문제 설명

Captain Jean-Luc Picard and the crew of the U.S.S. Enterprise NCC-1701-D have been dispatched yet again to negotiate a peace treaty, this time between two warring cultures, the Decimators and the Fractionalists. They have fought for many years over the correct way to represent rational numbers. The Decimators represent each rational number as a possibly repeating decimal number, such 0.444... (which they write as 0.(4) with parentheses to denote the repeated part), whereas the Fractionalists represent each rational number as a fraction, such as 4/9. After a devastating war in which hundreds of millions died, the Fractionalists have won. The crew of the U.S.S. Enterprise has the task of converting all numbers in the treaty to fractional form.

입력 설명

The input contains a single test case.

The input consists of a positive rational number, represented as a possibly repeating decimal number. The whole number part comes first, and is always present. The whole number part may then be followed by both a period and a decimal part. The decimal part may end with a repeating part, which is contained in parentheses. For example, 0.(4) represents the repeating decimal number 0.444. . . . There is no whitespace within a line. Each test case is no more than 10 characters long.

 

last input is possible "END" or EOF(end of file)

출력 설명

 

Output a single line containing a fraction representing the input rational number. The fraction must be in reduced form i.e. the numerator and denominator contain no common factor.

입력 예시 Copy

0.(6)

출력 예시 Copy

2/3