#P3637. Find a Fraction

    ID: 2519 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2010 ACM-ICPC Multi-University Training Contest(19)——Host by HDU

Find a Fraction

Problem Description

Given two non-negative rational numbers A and B(A<B), your task is to find a fraction between (A,B).
Maybe there're many fractions in this interval. In this condition, output the fraction with the smallest sum of its denominator and molecular.

Input

The first line is an integer T(<=25) indicating the case number.
The next T lines each contains two strings, namely A and B.
A rational number contains characters '0'~'9','.','[',']' only.
Digits between '[' and ']' are recurring decimal's cycle parts.(0.[6] = 0.666...,etc.)
You may assume the input are all logical, and all the strings are no more than 16.

Output

For each case, output a fraction(as the format below) with the smallest sum of its denominator and molecular.

4 0 0.5 0.[6] 0.[7] 11.0[8] 11.1[5] 1.[142857] 3.[142857]
Case 1: 1/3 Case 2: 3/4 Case 3: 78/7 Case 4: 2/1

Author

MadFrog