시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 336 98 90 30.822%

문제

유리수 분수를 소수로 나타내면, 소수점 아래 자리가 유한 개인 경우(1/8 = 0.125)와 어떤 자리에서부터 일정한 숫자가 한없이 되풀이 되는 경우(1/11 = 0.090909...)가 있다.

소수를 입력받은 뒤, 분수로 나타내는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수가 주어진다. 테스트 케이스의 개수는 100개를 넘지 않는다. 각 테스트 케이스는 한 줄에 소수가 하나씩 주어진다.

소수의 첫 두 자리는 "0."이다. 그 다음에는 숫자 0개~6개가 주어진다. 그 다음, 길이가 1과 9사이면서 괄호로 감싸져있는 수가 주어질 수도 있다. 이 수는 무한히 반복되는 자리를 의미한다.

항상 0이 아닌 자리가 하나는 주어지며, 괄호 안에 주어지는 수는 0이나 9로만 이루어져 있지 않다.

출력

각 테스트 케이스에 대해서, 입력으로 주어진 소수의 분수 표현을 출력한다. (분모와 분자는 서로소이어야 한다)

예제 입력 1

3
0.5
0.(3)
0.6(142857)

예제 출력 1

1/2
1/3
43/70
W3sicHJvYmxlbV9pZCI6IjUzNzYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMxOGNcdWMyMThcdWI5N2MgXHViZDg0XHVjMjE4XHViODVjIiwiZGVzY3JpcHRpb24iOiI8cD5cclxuXHRcdWM3MjBcdWI5YWNcdWMyMTggXHViZDg0XHVjMjE4XHViOTdjIFx1YzE4Y1x1YzIxOFx1Yjg1YyBcdWIwOThcdWQwYzBcdWIwYjRcdWJhNzQsIFx1YzE4Y1x1YzIxOFx1YzgxMCBcdWM1NDRcdWI3OTggXHVjNzkwXHViOWFjXHVhYzAwIFx1YzcyMFx1ZDU1YyBcdWFjMWNcdWM3NzggXHVhY2JkXHVjNmIwKDFcLzggPSAwLjEyNSlcdWM2NDAgXHVjNWI0XHViNWE0IFx1Yzc5MFx1YjlhY1x1YzVkMFx1YzExY1x1YmQ4MFx1ZD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