177482025-09-17 09:21:16SMC40A sárkány feladványa (50)cpp17Wrong answer 32/502ms500 KiB
#include <bits/stdc++.h>
using namespace std;

int lcm(int a,int b){
    int g=max(a,b),s=a+b-g;
    for (int i = g; i <= a * b; i += g) {
        if (i % s == 0)
            return i;
    }
}
int num(int n){
    int i=1;
    while(n>=10){
        n/=10;
        i++;
    }
    return i;
}

int main() {
	int t=3;
    while(t--){
        int a, b, n;
        cin>>a>>b>>n;
        long long e=lcm(a,b),cnt=num(e);
        if(cnt>n){
            cout<<-1<<"\n";
            continue;
        }
        cout<<e;
        while(cnt<n){
            cout<<0;
            cnt++;
        }
        cout<<"\n";
    }    
}
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms320 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms500 KiB
7Accepted3/31ms328 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/32ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/32ms316 KiB
13Wrong answer0/41ms404 KiB
14Accepted4/41ms316 KiB
15Accepted4/41ms316 KiB
16Wrong answer0/41ms316 KiB
17Wrong answer0/41ms316 KiB