Cod sursa(job #3004213)

Utilizator iProgramInCppiProgramInCpp iProgramInCpp Data 16 martie 2023 10:37:59
Problema GFact Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("gfact.in");
ofstream fout("gfact.out");
int p,q;

int contains(int x, int p)
{
    int result = 0;

    while (x % p == 0)
    {
        x /= p;
        result++;
    }

    return result;
}

int main()
{
    fin >> p >> q;

    int i = 1, cnt = 0;
    for (; cnt < q; i++)
    {
        cnt += contains(i, p);
    }

    fout << i-1;

    return 0;
}