148182025-02-03 12:04:05szjA sárkány feladványa (50)cpp17Wrong answer 32/5020ms864 KiB
#include <bits/stdc++.h>

using namespace std;
int t[100000];
bool prim(int n)
{
    for(int i=2; i<=ceil(sqrt(n)); i++)
    {
        if(n%i == 0)return 0;
    }
    return 1;
}
int lkkt(int a, int b)
{
    long int l=1;
    int o;
    for(int i=1; i<100000 && !(a==1 && b==1); i++)
    {
        if(t[i])
        {
            o = i+1;
            while(a%o==0 && b%o==0)
            {
                a/=o;
                b/=o;
                l*=o;
            }
            while(a%o==0)
            {
                a/=o;
                l*=o;
            }
            while(b%o==0)
            {
                b/=o;
                l*=o;
            }
        }
    }
    return l;
}
int main()
{
    int a, b, n, j, i;
    for(j=1; j< 100000; j++)
    {
        if(prim(j+1))t[j] = 1;
        else t[j] = 0;
    }
    t[1] = 1;
    string s;
    for(j = 0; j<3; j++)
    {
        cin >> a >> b >> n;
        s = to_string(lkkt(a, b));
        if(s.size() > n)cout << -1;
        else
        {
            cout << s;
            for(i = 0; i<n-s.size(); i++)cout << 0;
        }
        cout << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/020ms564 KiB
2Accepted0/020ms564 KiB
3Accepted3/320ms564 KiB
4Accepted3/320ms564 KiB
5Accepted3/320ms564 KiB
6Accepted3/320ms748 KiB
7Accepted3/320ms680 KiB
8Wrong answer0/320ms760 KiB
9Wrong answer0/320ms564 KiB
10Accepted3/320ms564 KiB
11Accepted3/320ms564 KiB
12Accepted3/320ms864 KiB
13Wrong answer0/420ms712 KiB
14Accepted4/420ms756 KiB
15Accepted4/420ms564 KiB
16Wrong answer0/420ms684 KiB
17Wrong answer0/420ms756 KiB