Cod sursa(job #355989)
Utilizator | Data | 12 octombrie 2009 22:22:23 | |
---|---|---|---|
Problema | GFact | Scor | 20 |
Compilator | cpp | Status | done |
Runda | CNRV #2 | Marime | 0.35 kb |
# include <fstream.h>
# include <math.h>
int main(){
long long a,p,q,b;
int i,j,ok,d;
ifstream f("gfact.in");
ofstream g("gfact.out");
f>>p>>q;
a=pow(p,q);
ok=1;d=0;
while(ok){b=1;
for(i=1;i<=d;i++)b*=i;
if(b%a==0)ok=0;
else d++;
}
g<<d;
f.close();
g.close();
return 0;
}