401610: GYM100499 I Fraction

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Fractiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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.

Input

The 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.

Output

For each test, print the result in one line in the format Case #x: a/b

ExamplesInput
4
0.125
0.(142857)
0.1(6)
.2
Output
Case #1: 1/8
Case #2: 1/7
Case #3: 1/6
Case #4: 1/5

加入题单

上一题 下一题 算法标签: