Cod sursa(job #300065)
Utilizator | Data | 7 aprilie 2009 11:04:57 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.33 kb |
#include<fstream.h>
main()
{long p,n=0,cont=1,c;
ifstream i("fact.in");
ofstream o("fact.out");
i>>p;
while(p--)
{n=n+5;
c=cont;
while(cont%5==0)
{p--;cont/=5;}
cont=c;
cont++;
if(p<0)
break;
}
if(p<0)
o<<"-1"<<'\n';
else
o<<n<<'\n';
i.close();
o.close();
return 0;
}