Cod sursa(job #458514)
Utilizator | Data | 25 mai 2010 08:45:15 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.33 kb |
#include<cstdio>
#include<fstream>
using namespace std;
int p;
long long a;
int main ()
{
ifstream in ("fact.in");
freopen("fact.out","w",stdout);
in>>p;
in.close();
if(p==0)
printf("1\n");
else{
for(int i=1,c=1;c<=p;++i,++c,a+=5){
if(i%5==0){
int x=i,pp=0;
while(x%5==0)
x/=5,++pp;
c+=pp;
}
}
printf("%lld\n",a);
}
return 0;}