Mai intai trebuie sa te autentifici.
Cod sursa(job #1883927)
Utilizator | Data | 18 februarie 2017 12:17:05 | |
---|---|---|---|
Problema | GFact | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#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 <= INT64_MAX; i++ )
{
fact = 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;
}