147052025-01-28 19:26:16feheristvanA sárkány feladványa (50)cpp17Wrong answer 15/501ms500 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int countDigit(int n) {
      // Base case
    if (n == 0)
        return 1;

    int count = 0;

      // Iterate till n has digits remaining
    while (n != 0) {

          // Remove rightmost digit
        n = n / 10;

          // Increment digit count by 1
        ++count;
    }
    return count;
}

int lnko(int a, int b){
    int m;
    do{
        m = a % b;
        a = b;
        b = m;
    }while(b != 0);
    return a;
}

int lkkt(int a, int b){
    return a * b / lnko(a, b);
}

int main()
{
    int a, b, n, lk;
    for(int i = 0 ; i < 3; i ++){
        cin >> a >> b >> n;
        lk = lkkt(a, b);
        if(countDigit(lk) == n){
            cout << lk << endl;
        }
        else if(countDigit(lk) > n)
            cout << -1 << endl;
        else{
            cout << lk * pow(10, n - countDigit(lk)) << endl;
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms500 KiB
3Accepted3/31ms500 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/31ms316 KiB
12Wrong answer0/31ms316 KiB
13Wrong answer0/41ms316 KiB
14Wrong answer0/41ms316 KiB
15Wrong answer0/41ms316 KiB
16Wrong answer0/41ms316 KiB
17Wrong answer0/41ms316 KiB