Cod sursa(job #1178633)
Utilizator | Data | 26 aprilie 2014 23:08:52 | |
---|---|---|---|
Problema | GFact | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
ifstream in("gfact.in");
ofstream out("gfact.out");
int t;in>>t;
while(t){
int p,q,ok=0;
in>>p>>q;
long long a=pow(p,q),b=0;
while(ok==0)
{
b++;
long long y=1,fact=1;
while(y<=b)
{
fact=fact*y;
y++;
}
if(fact%a==0)ok=1;
}
out<<b<<"\n";
t--;
}
in.close();
out.close();
return 0;
}