## JDCC '15 Contest 1 P4 - Basically Right

View as PDF

Points: 7
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Eve, like many other students, wants to get a high mark. However, she "forgot" to study for her ICS exam and is shocked at the mark she received! Deciding to argue her grade, she thinks of the following plan: the teacher wrote down her mark as a fraction, but they never specified what base it's in, so to get a higher mark Eve can argue that her mark is given in a base other than 10. After doing some spying, she figures out that the teacher approves of this idea, however they limit the new base to be smaller than the denominator. Eve also has the option to not argue her mark. As someone who studied for their exam, help Eve figure out what is the best mark that she can receive.

Note: A number in base means that instead of the place values being ones, tens, hundreds, etc., they are ones, 's, 's, etc. For example, in base the number is . In base , it's . Numbers expressed in base can't have digits greater than or equal to (e.g. you can't have in base ). To convert out of base , multiply each digit by its place value and add them together (e.g. in base is ).

#### Input Specification

The first line of the input provides the number of test cases, . test cases follow, each test case consisting of two integers and , the numerator and denominator of her grade.

#### Output Specification

For each test case, output the percent value of the highest possible mark she can achieve by changing the base, rounded to 6 decimal places.

#### Sample Input

3
11 100
12 23
43 57

#### Sample Output

75.000000
54.545455
79.094077

#### Explanation for Sample

In the first case, Eve should argue the mark is in base , which would make it .