#P2118. [NOIP 2014 普及组] 比例简化
[NOIP 2014 普及组] 比例简化
Description
On social media, it is common to see polls and their results about whether people agree with a certain viewpoint. For example, if people support it and oppose it, then the ratio of support to opposition can be written simply as .
However, most people would not be satisfied if the results were presented this way, because the numbers in the ratio are too large and it is hard to see the relationship at a glance. For the example above, if the ratio is written as , although there is some error compared with the true result, it still reflects the poll result fairly accurately and is more intuitive.
Given the number of supporters , the number of opponents , and an upper bound , please reduce to into to under the conditions that and are both no greater than and and are coprime (the greatest common divisor of the two integers is ), such that and the value of is as small as possible.
Input Format
One line containing three integers , separated by a single space, representing the number of supporters, the number of opponents, and the upper bound.
Output Format
One line containing two integers , separated by a single space, representing the simplified ratio.
1498 902 10
5 3
Hint
For of the testdata, $1 \le A \le 10^6, 1 \le B \le 10^6, 1 \le L \le 100, \dfrac{A}{B} \le L$.
Translated by ChatGPT 5
京公网安备 11011102002149号