Cod sursa(job #274115)
| Utilizator | Data | 9 martie 2009 14:13:20 | |
|---|---|---|---|
| Problema | GFact | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <fstream.h>
#include <math.h>
ifstream f("gfact.in");
ofstream g("gfact.out");
long long p, A, factmax,temp=1;
int q;
void ReadData()
{
f>>p>>q;
f.close();
}
void CX()
{
A=pow(p,q);
factmax=p*q;
}
int factorial(int x)
{
if(x==0 ||x ==1) return 1;
else
return x*factorial(x-1);
}
int CX2()
{
for(int i=1;i<=factmax;i++)
if(factorial(i)%A==0 && factorial(i)>=A)
return i;
}
int main(){
ReadData();
CX();
g<<CX2();
g.close();
return 0;
}
