43122023-03-23 12:18:21gkataA sárkány feladványa (50)cpp17Hibás válasz 29/503ms4384 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;

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