Cod sursa(job #273992)
Utilizator | Data | 9 martie 2009 12:17:51 | |
---|---|---|---|
Problema | GFact | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<iostream>
#include<math.h>
#include<fstream>
using namespace std;
long long p,a;
int q;
long b;
ifstream f ("gfact.in");
ofstream g ("gfact.out");
int fact(long x)
{
if(x==0||x==1) return 1;
else return x*fact(x-1);
}
int main()
{ f>>p>>q;
a=pow(p,q);
int k=1;
for(long i=1;i<=p*q && k;i++) if(fact(i) % a==0) {k=0;b=i;}
g<<b;
return 0;
}