Hozirda online


Masalalar soni: 909

Foydalanuvchilar soni: 8825

Jo'natishlar soni: 714634

Muhokama yozuvlari: 4541

Yangiliklar soni: 98

Yangiliklar izohlari: 1179

So'ngi izohlar

788. Integer Approximation
Vaqt limiti: 1 sekund
Xotira limiti: 64 MB

The FORTH programming language does not support floating-point arithmetic at all. Its author, Chuck Moore, maintains that floating-point calculations are too slow and most of the time can be emulated by integers with proper scaling. For example, to calculate the area of` the circle with the radius R he suggests to use formula like R * R * 355 / 113, which is in fact surprisingly accurate. The value of 355 / 113 ≈ 3.141593 is approximating the value of π with the absolute error of only about 2·10–7. You are to find the best integer approximation of a given floating-point number A within a given integer limit L. That is, to find such two integers N and D (1 £ ND £ L) that the value of absolute error |AN / D| is minimal.


The first line of input contains a floating-point number A (0.1 £ A < 10) with the precision of up to 15 decimal digits. The second line contains the integer limit L. (1 £ L £ 100000).


Output must contain two integers, N and D, separated by a space. If there are several solutions output the one with smallest D.







355 113


Tayyorladi: Azat Yusupov
Text from: FarEastern subregional
Mening urinishlarim(0) Muhokama (0) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(22) Barcha urinishlar(98)