Cod sursa(job #440805)
Utilizator | Paul Buda paul_gabryel | Data | 12 aprilie 2010 15:51:18 |
---|---|---|---|
Problema | Factorial | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<iostream>
#include<fstream>
#include<cstdio>
using namespace std;
int p,c;
int help (int x)
{
int pp=0;
while(x%5==0){
x/=5;
++pp;
}
return pp;
}
int main ()
{
ifstream fin ("fact.in");
freopen("fact.out","w",stdout);
fin>>p;
int aux=0;
if(p==0)
printf("1\n");
else{
c=1;
for(int i=1;i<=p&&c<=p;++i){
aux+=5;
++c;
if(i%5==0)
c+=help(i);
}
printf("%d\n",aux);
}
return 0;
}