Please be easy!#12361

Please be easy! (Editorial)

Problem Author:

Aritro Sarkar

textbfPrepared by:

Hasan Saleh (MathModel)

textbfEdited by:

Hasan Saleh (MathModel)

Solution

The solution can be claimed by observing the pattern for (a,b,k \le 50) or similar bounds , we can verify that the answer is exactly \displaystyle \frac{a}{b} and actually doesn't matter.

Proof :

By Algebraic Representation : Since and both have digits, repeating a number for times can be expressed as a geometric series. Specifically:

f(x, k) = x \cdot (1 + 10^L + 10^{2L} + \dots + 10^{(k-1)L})

thus

\frac{f(a,k)}{f(b,k)}=\frac{a \cdot (1 + 10^L + 10^{2L} + \dots + 10^{(k-1)L})}{b \cdot (1 + 10^L + 10^{2L} + \dots + 10^{(k-1)L})}=\frac{a}{b}

thus we divide both by their greatest common divisor to get the irreducible fraction.

Complexity O(t \cdot \log(10^{15}) which is at most operations under the current constraints.

from math import gcd
def solve():
    a,b,k=map(int,input().split())
    print(a//gcd(a,b),b//gcd(a,b))
for _ in range(int(input())):
    solve()