Hide

Problem G
Rationalization

Languages en sv

Having recently read about Pythagoras, Doris has become convinced that there are no irrational numbers! She claims that every number can be written as the quotient of two whole numbers $A$ and $B$. As an exercise, she has decided to find these ratios for some positive physical constants. Because every constant has some error $F$, she only wants a ratio with a quotient between $C-F$ and $C+F$. Furthermore, since she dislikes long numbers, she wants to find the pair $A$, $B$, whose quotient lies within the interval and has the smallest $A$. If there are many such $A$, she chooses the pair $A$, $B$ with smaller $B$. Can you help her accomplish this goal?

Input

The first contains two positive real numbers $C, F$, ($0 < C \leq 10$), ($10^{-8} \leq F \leq 0.1$), the desired quotient and the margin for error, both in decimal form with at most 6 significant digits.

Output

Print two lines with one positive integer each, $A$ and $B$. It is guaranteed that these are less than $10^6$.

Grading

Your solution will be tested on a number of test-case groups. To receive points for a group, your solution must correctly solve every test-case in the group.

Group

Point value

Restrictions

$1$

$20$

$B = 1000$

$2$

$40$

$A, B \leq 10^{3}$

$3$

$40$

No further restrictions

Sample Input 1 Sample Output 1
0.01 0.001
1
91
Sample Input 2 Sample Output 2
4.71344 0.0000091295
1579
335
Sample Input 3 Sample Output 3
0.333 0.00000001
333
1000

Please log in to submit a solution to this problem

Log in