Cod sursa(job #357998)
Utilizator | Data | 21 octombrie 2009 17:23:33 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.28 kb |
#include<fstream.h>
#include<math.h>
int main()
{
int p,n,b,k,x;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
k=0;
n=0;b=1;
while(k<p)
{
n+=5; k++;
x=pow(5,b);
if(k%x){k+=b-1;b++;}
}
g<<n;
f.close();
g.close();
return 0;
}