Pagini recente » Autentificare | arena | Istoria paginii runda/oni17_11_12_z1 | Cod sursa (job #1388385) | Cod sursa (job #1883931)
#include <iostream>
#include <fstream>
using namespace std;
long long find(long long P, long long Q){
long long fact = 1;
for(long long i = 1; i <= INT8_MAX; i++ )
{
fact = i;
while(fact % P == 0)
{
Q--;
fact = fact/P;
}
if(Q == 0)
{
return i;
}
}
return -1;
}
int main() {
long long P,Q;
ifstream in("gfact.in");
ofstream out("gfact.out");
in >> P >> Q;
out << find(P,Q);
return 0;
}