Cod sursa(job #30187)

Utilizator buradaandreiBurada Andrei buradaandrei Data 13 martie 2007 10:22:04
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <fstream.h>
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
unsigned long n,i=0,nr5=0,nr0=0;
f>>n;
while (nr0<n)
	{
	i+=5;
	int aux=i;
	while (aux%5==0)
		{
		nr5++;
		aux/=5;
		}
	if (nr5>=1)
		{
		nr0+=nr5;
		nr5=0;
		}
	}
if (n==0)
	i++;
if (nr0==n)
	g<<i;
else
	g<<-1;
return 0;

}