Cod sursa(job #521075)

Utilizator Antonius74Antonius Cezar Hegyes Antonius74 Data 11 ianuarie 2011 08:21:17
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <cstdio>
int main()
{

	freopen ("fact.in","r",stdin);
	freopen ("fact.out","w",stdout);
	
	int p,x=0,y=0,i=0,j=0,aux;
	scanf ("%d",&p);
	
	while ((i<p) || (j<p))
	{
		x+=5;
		aux=x;
		while (aux%5==0)
		{
			aux/=5;
			i++;
		}
		y+=2;
		aux=y;
		while (aux%2==0)
		{
			aux/=2;
			j++;
		}
		y+=2;
		aux=y;
		while (aux%2==0)
		{
			aux/=2;
			j++;
		}
	}
	if (i>p)
		printf ("-1 \n");
	else
		if (p==0)
			printf ("1 \n");
		else
			printf ("%d \n",x);
	
	

}