1511B - GCD Length - CodeForces Solution


constructive algorithms math number theory *1100

Please click on ads to support us..

Python Code:

import sys

input = sys.stdin.readline


def solve():
    a, b, c = map(int, input().split())
    cnt1, cnt2 = a-(c-1), b-(c-1)
    gcd = 10**(c-1)
    X = Y = 1
    while len(str(X)) < cnt1:
        X *= 2
    while len(str(Y)) < cnt2:
        Y *= 3
    return X*gcd, Y*gcd


for _ in range(int(input())):
    print(*solve())

C++ Code:

#include <bits/stdc++.h>
#define int long long
#define float double
using namespace std;
int power(int n)
{
    if (n == 0)
        return 1;
    return 10 * power(n - 1);
}
void solve()
{

    int a, b, c, x, y;
    cin >> a >> b >> c;
    x = power(a - 1);
    cout << x << " ";
    int temp = power(b - 1);
    y = power(c - 1) + temp;
    cout << y << endl;
}
int32_t main()
{
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

1428B - Belted Rooms
519B - A and B and Compilation Errors
1152B - Neko Performs Cat Furrier Transform
1411A - In-game Chat
119A - Epic Game
703A - Mishka and Game
1504C - Balance the Bits
988A - Diverse Team
1312B - Bogosort
1616B - Mirror in the String
1660C - Get an Even String
489B - BerSU Ball
977C - Less or Equal
1505C - Fibonacci Words
1660A - Vasya and Coins
1660E - Matrix and Shifts
1293B - JOE is on TV
1584A - Mathematical Addition
1660B - Vlad and Candies
1472C - Long Jumps
1293D - Aroma's Search
918A - Eleven
1237A - Balanced Rating Changes
1616A - Integer Diversity
1627B - Not Sitting
1663C - Pōja Verdon
1497A - Meximization
1633B - Minority
688B - Lovely Palindromes
66B - Petya and Countryside