Phân Số

PDF

Submit solution

Points: 10.00 (partial)
Time limit: 1.0s
Memory limit: 64M
Input: stdin
Output: stdout

Problem type
Allowed languages
C, C++, Java, Pascal, Python, Scratch, TEXT

Cho số số thực dương ~x~ và số nguyên dương ~n~.

Yêu cầu

Hãy tìm phân số tối giản ~\displaystyle\frac{a}{b}~ thỏa mãn ~1\le b\le n~ và giá trị phân số ~\displaystyle\frac{a}{b}~ gần với ~x~ nhất.

Dữ liệu

Dòng 1 chứa số thực dương ~x~ ~(x<1)~ với ~9~ chữ số sau dấu chấm thập phân (dạng ~0.?????????~).
Dòng 2 chứa số nguyên dương ~n~ ~(n\le 10^7)~.

Kết quả

Ghi ra hai số nguyên ~a~, ~b~ trên một dòng cách nhau ít nhất một dấu cách xác định phân số tối giản ~\displaystyle\frac{a}{b}~ tìm được.

Input

0.666666667
5

Output

2 3

Comments

Please read the guidelines before commenting.


There are no comments at the moment.