Cod sursa(job #1883859)
| Utilizator | Data | 18 februarie 2017 11:41:29 | |
|---|---|---|---|
| Problema | GFact | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
long long find(long long A){
long long fact = 1;
for(long long i = 1; i <= A; i++ )
{
fact = fact * i;
if( fact % A == 0 )
return i;
}
return -1;
}
int main() {
long long P,Q;
long long A;
ifstream in("gfact.in");
ofstream out("gfact.out");
in >> P >> Q;
A = pow(P,Q);
out << find(A);
return 0;
}