Cod sursa(job #2349176)
Utilizator | Data | 20 februarie 2019 11:09:39 | |
---|---|---|---|
Problema | GFact | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("gfact.in");
ofstream out("gfact.out");
int main()
{
long long n,m,nrq,lst=1,ldr=100,c,p,q,aux;
in>>p>>q;
if(n==0)
{
out<<1;
return 0;
}
while(lst <= ldr)
{
m = lst;
c=0;
aux=p;
while(m >= aux)
{
c += m / aux;
aux *= p;
}
nrq=c;
if(nrq>=q)
{
m-=m%p;
out<<m;
return 0;
}
else if(nrq<q)
lst = m + 1;
}
return 0;
}