Cod sursa(job #645751)

Utilizator an_drey_curentandreycurent an_drey_curent Data 10 decembrie 2011 14:25:35
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include<stdio.h>
#include<math.h>
long int nr_zerouri(long int x)
{
	long int aux=x,suma=0;
	while(x!=0)
	{
		suma+=x%5;
		x=x/5;
	}
	return (aux-suma)/4;
}
int main()
{
	long int max,i,cerinta,P;
	freopen("fact.in","r",stdin);
	freopen("fact.out","w",stdout);
	scanf("%d",&P);
	if(P==0)
		printf("1");
	else
	{
	cerinta=P;
	P=4*P;
	while(P%5!=0)
		P++;
	i=P;
	max=P+200;
	for(i=P;i<=max;i+=5)
		if(nr_zerouri(i)==cerinta)
		{printf("%d",i);break;}
	if(i>max)
		printf("-1");
	}
	return 0;
}