95942024-02-23 13:57:19zeytonxA sárkány feladványa (50)cpp17Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1828 KiB
2Elfogadva0/03ms2052 KiB
3Elfogadva3/33ms2140 KiB
4Elfogadva3/33ms2364 KiB
5Elfogadva3/33ms2596 KiB
6Elfogadva3/33ms2808 KiB
7Elfogadva3/33ms2876 KiB
8Elfogadva3/34ms3104 KiB
9Elfogadva3/33ms3320 KiB
10Elfogadva3/33ms3492 KiB
11Elfogadva3/33ms3716 KiB
12Elfogadva3/33ms3936 KiB
13Elfogadva4/44ms3948 KiB
14Elfogadva4/43ms4048 KiB
15Elfogadva4/43ms4132 KiB
16Elfogadva4/43ms4116 KiB
17Elfogadva4/44ms4116 KiB