GCD Length (Codeforces 1511B)
Tags: Math, number theory

You are given three integers $$$a$$$, $$$b$$$ and $$$c$$$.Find two positive integers $$$x$$$ and $$$y$$$ ($$$x > 0$$$, $$$y > 0$$$) such that:   the decimal representation of $$$x$$$ without leading zeroes consists of $$$a$$$ digits;  the decimal representation of $$$y$$$ without leading zeroes consists of $$$b$$$ digits;  the decimal representation of $$$gcd(x, y)$$$ without leading zeroes consists of $$$c$$$ digits. $$$gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.Output $$$x$$$ and $$$y$$$. If there are multiple answers, output any of them.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 285$$$) — the number of testcases.Each of the next $$$t$$$ lines contains three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b \le 9$$$, $$$1 \le c \le min(a, b)$$$) — the required lengths of the numbers.It can be shown that the answer exists for all testcases under the given constraints.Additional constraint on the input: all testcases are different.

Output: For each testcase print two positive integers — $$$x$$$ and $$$y$$$ ($$$x > 0$$$, $$$y > 0$$$) such that   the decimal representation of $$$x$$$ without leading zeroes consists of $$$a$$$ digits;  the decimal representation of $$$y$$$ without leading zeroes consists of $$$b$$$ digits;  the decimal representation of $$$gcd(x, y)$$$ without leading zeroes consists of $$$c$$$ digits. 

Note: In the example:   $$$gcd(11, 492) = 1$$$  $$$gcd(13, 26) = 13$$$  $$$gcd(140133, 160776) = 21$$$  $$$gcd(1, 1) = 1$$$ 

Sample Inputs:
4
2 3 1
2 2 2
6 6 2
1 1 1

Sample Outputs:
11 492
13 26
140133 160776
1 1

Solution (Python):
import math
for _ in range(int(input())):
    (a, b, c) = map(int, input().split())
    g = int('1' + '0' * (c - 1))
    if g == 1:
        print(int('1' + '0' * (a - 1)), int('1' + '0' * (b - 1)) + 1)
    else:
        g += 1
        x = int('1' + '0' * (a - 1))
        y = int('1' + '0' * (b - 1))
        ra = x // g if x % g == 0 else x // g + 1
        rb = y // g if y % g == 0 else y // g + 1
        x = g * ra + g
        y = g * rb
        if x == 0:
            x += g
        if y == 0:
            y += g
        if x == y:
            x += g
        print(x, y)

Solution (Python):
for t in range(int(input())):
    (a, b, c) = map(int, input().split())
    print('1' + '0' * (a - 1), '1' * (b - c + 1) + '0' * (c - 1))

Solution (Python):
t = int(input())
for i in range(t):
    (a, b, c) = map(int, input().split())
    if a == b == c:
        print(10 ** (a - 1), 10 ** (a - 1))
    elif min(a, b) == c:
        print(10 ** (a - 1), 10 ** (b - 1))
    elif a == b and c == 1:
        print(10 ** (a - 1), 10 ** (a - 1) + 1)
    elif a == b and c != 1:
        x = a - c
        print((10 ** (c - 1) + 1) * 10 ** x, (10 ** (c - 1) + 1) * 11 ** x)
    elif a != b and c == 1:
        print(10 ** (a - 1), 10 ** (b - 1) + 1)
    elif a != b and c != 1:
        print((10 ** (c - 1) + 1) * 10 ** (a - c), (10 ** (c - 1) + 1) * 11 ** (b - c))