2649. Pie Party

单点时限: 3.0 sec

内存限制: 256 MB

A party is held every year on the anniversary of the founding of Imo Creative Production Company.The number of the participants of the party is increasing year by year.

Traditionally pies are served in the party. And it is also known that each pie is divided equally into N parts and N is a unique integer to each year. The number of the participants, however,is not predictable and may not be exactly a multiple of N, so some pieces may be left after each participant received a piece of the pies.

But this year the chief cook carelessly has forgotten the number N, and regrettably there is no record but the amount R of the pieces of pies which are eaten by them and the upper limit of the unique integer L.

Your mission is to write a program to estimate two coprime integer, the number P of participants and the unique integer N, that minimize| R - P/N |(1 ≤ N ≤ L).

输入格式

The input consists of multiple datasets, each of which contains one decimal fraction R and one integer L. R is the amount of pieces of the pies which are eaten, and L is the upper limit of the unique integer.

You may assume the following.

0 < R < 5

0 < L < 10, 000, 000

The end of the input is indicated by a line containing two zeroes.

输出格式

For each dataset, output a line containing the number P of participants and a unique integer N whose greatest common divisor is 1.

The output must be written to standard output.

样例

Input
3.14159265358979 10
0.12500000000000 100
0.00000000000000 0
Output
22 7
1 8

12 人解决,19 人已尝试。

35 份提交通过,共有 123 份提交。

6.0 EMB 奖励。

创建: 15 年,4 月前.

修改: 7 年,3 月前.

最后提交: 5 年前.

来源: The 1st Imos Contest

题目标签