Cod sursa(job #518515)

Utilizator Antonius74Antonius Cezar Hegyes Antonius74 Data 1 ianuarie 2011 16:18:39
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <cstdio>
using namespace std;
int main()
{
	freopen("fact.in","r",stdin);
	freopen("fact.out","w",stdout);
	
	int p,x,y=-1,t=0;
	bool nicht=false;
	scanf ("%d",&p);
	
	x=5*p;
	
	while (y<p)
	{
		y+=6;
		t++;
		if (p==y)
			nicht=true;
	}
	y=5;
	while (y<x)
	{
		y*=5;
		t++;
	}
	t-=3;
	t*=5;
	x-=t;
	
	
	if (nicht==false)
		printf ("%d \n",x);
	else
		printf ("-1 \n");
}