20562022-12-16 00:13:32kovacs.peter.18fA sárkány feladványa (50)cpp11Accepted 50/503ms4504 KiB
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return (a / gcd(a, b)) * b;
}

int digits(long long n) {
    int result = 0;
    while (n) {
        n /= 10;
        ++result;
    }
    return result;
}

void task() {
    long long A, B, N;
    cin >> A >> B >> N;
    long long m = lcm(A, B);
    if (digits(m) > N) {
        cout << "-1\n";
        return;
    }
    cout << m;
    for (int i = digits(m); i < N; i++) {
        cout << 0;
    }
    cout << '\n';
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    for (int i = 0; i < 3; i++) {
        task();
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1892 KiB
2Accepted0/02ms2120 KiB
3Accepted3/32ms2324 KiB
4Accepted3/32ms2392 KiB
5Accepted3/32ms2588 KiB
6Accepted3/32ms2820 KiB
7Accepted3/32ms2900 KiB
8Accepted3/32ms3032 KiB
9Accepted3/32ms3228 KiB
10Accepted3/32ms3408 KiB
11Accepted3/32ms3608 KiB
12Accepted3/32ms3816 KiB
13Accepted4/42ms3888 KiB
14Accepted4/42ms4020 KiB
15Accepted4/42ms4224 KiB
16Accepted4/42ms4432 KiB
17Accepted4/42ms4504 KiB