Cod sursa(job #19802)

Utilizator hazegirlCatalina Predoi hazegirl Data 19 februarie 2007 23:27:06
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.35 kb
#include<fstream.h>
int main()
{long int p,z,i,q;
ifstream f("fact.in");
f>>p;
f.close();
i=0; q=p;
while(q>7)
{i+=25;
q-=6;
z=i/25;
while(z%5==0){q--;z/=5;}}
while(q>0)
	{i+=5;
	 z=i; do
	      {q--;
	       z/=5;}
	       while(z%5==0);}
ofstream g("fact.out");
if(p==0) g<<"1";
else if(q==0) g<<i; else g<<"-1";
g.close();
return 0;
}