#P1298. 最接近的分数
最接近的分数
Description
Given a positive decimal number, find a reduced fraction or an integer whose numerator (numerator ) does not exceed and denominator does not exceed , such that it is closest to the given decimal on the number line. If this closest fraction is not unique, output TOO MANY.
Input Format
There are lines of input. The first line contains two space-separated positive integers and , indicating that the fraction’s numerator does not exceed and the denominator does not exceed . The second line contains a decimal ; the integer part of is a single Arabic digit, and the fractional part has at most ten digits.
Output Format
Output exactly line. If the solution is unique, output numerator/denominator (an integer should be written as ); otherwise output TOO MANY.
360 120
3.1415926536
355/113
Hint
Constraints
For all testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号