#P2118. [NOIP 2014 普及组] 比例简化

    ID: 1074 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学2014NOIp 普及组最大公约数,gcd

[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 14981498 people support it and 902902 oppose it, then the ratio of support to opposition can be written simply as 1498:9021498:902.

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 5:35:3, 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 AA, the number of opponents BB, and an upper bound LL, please reduce AA to BB into AA' to BB' under the conditions that AA' and BB' are both no greater than LL and AA' and BB' are coprime (the greatest common divisor of the two integers is 11), such that ABAB\dfrac{A'}{B'} \ge \dfrac{A}{B} and the value of ABAB\dfrac{A'}{B'} - \dfrac{A}{B} is as small as possible.

Input Format

One line containing three integers A,B,LA,B,L, 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 A,BA',B', separated by a single space, representing the simplified ratio.

1498 902 10
5 3

Hint

For 100%100\% 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