401610: GYM100499 I Fraction
Description
A repeating decimal, also called a recurring decimal, is a number whose decimal representation eventually becomes periodic (i.e., the same sequence of digits repeats indefinitely). The repeating portion of a decimal expansion is conventionally denoted within a pair of brackets so, for example
1 / 6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66)
Both 0.1(6) or 0.1666(6) or 0.166(66) are correct representation of 1 / 6. Given a recurring decimal representation, your task is to find an irreducible fraction that has that representation.
InputThe first line of input contains the number of tests – T (T ≤ 100). Then T tests follow. Each test is printed in a line as a string whose length does not exceed 15. It is guaranteed to be a meaningful representation of a positive fraction.
OutputFor each test, print the result in one line in the format Case #x: a/b
ExamplesInput4Output
0.125
0.(142857)
0.1(6)
.2
Case #1: 1/8
Case #2: 1/7
Case #3: 1/6
Case #4: 1/5