95942024-02-23 13:57:19zeytonxA sárkány feladványa (50)cpp17Accepted 50/504ms4132 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef vector<vll> v2ll;
typedef map<ll,ll> mll;
typedef vector<pll> vpll;
#define fs first
#define sc second
#define pb push_back

const ll MOD = 1e9+7;

ll binpow(ll a, ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b % 2 == 0)
        {
            b /= 2;
            a *= a;
        }
        ans *= a;
        b--;
    }
    return ans;
}

void solve()
{
    ll a, b, c;
    cin >> a >> b >> c;
    mll primes_a, primes_b, primes;
    ll index = 2;
    while(a != 1)
    {
        while(a % index == 0)
        {
            primes_a[index]++;
            primes[index] = max(primes[index], primes_a[index]);
            a /= index;
        }
        index++;
    }
    index = 2;
    while(b != 1)
    {
        while(b % index == 0)
        {
            primes_b[index]++;
            primes[index] = max(primes[index], primes_b[index]);
            b /= index;
        }
        index++;
    }
    ll ans = 1;
    for(auto i : primes)
    {
        ans *= binpow(i.fs, i.sc);
    }
    string sans = to_string(ans);
    if(sans.size() == c)
        cout << sans << "\n";
    else
    if(sans.size() > c)
        cout << -1 << "\n";
    else
    {
        cout << sans;
        for(ll i = 0; i < c-sans.size(); i++)
            cout << "0";
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 3;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/03ms2052 KiB
3Accepted3/33ms2140 KiB
4Accepted3/33ms2364 KiB
5Accepted3/33ms2596 KiB
6Accepted3/33ms2808 KiB
7Accepted3/33ms2876 KiB
8Accepted3/34ms3104 KiB
9Accepted3/33ms3320 KiB
10Accepted3/33ms3492 KiB
11Accepted3/33ms3716 KiB
12Accepted3/33ms3936 KiB
13Accepted4/44ms3948 KiB
14Accepted4/43ms4048 KiB
15Accepted4/43ms4132 KiB
16Accepted4/43ms4116 KiB
17Accepted4/44ms4116 KiB