43132023-03-23 12:35:47gkataA sárkány feladványa (50)cpp17Elfogadva 50/503ms4100 KiB
#include <iostream>
#define ll long long

using namespace std;

//ifstream cin("s.in");
//ofstream cout("s.out");

ll a,b,n,i,k,l,r,sz,s,db,j;

int main()
{
    for(i=1;i<=3;++i)
    {
        db=0;
        cin>>a>>b>>n;
        k=a;
        l=b;

        r=a%b;
        while(r>0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        sz=k*l/b;
        s=sz;
        while(s>0)
        {
            s/=10;
            ++db;
        }
        //cout<<sz<<" "<<db<<"\n";

        if(db<=n)
        {
            cout<<sz;
            for(j=0;j<n-db;++j) cout<<0;
        }
        else cout<<-1;
        cout<<"\n";
    }
    return 0;
}