F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Find a Fraction

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 434    Accepted Submission(s): 93


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.
 

Sample Input
4 0 0.5 0.[6] 0.[7] 11.0[8] 11.1[5] 1.[142857] 3.[142857]
 

Sample Output
Case 1: 1/3 Case 2: 3/4 Case 3: 78/7 Case 4: 2/1
 

Author
MadFrog
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:16:06, Gzip enabled