Cod sursa(job #591422)

Utilizator Claudiu95Vartolomei Alexandru Claudiu Claudiu95 Data 24 mai 2011 01:25:34
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include<cstdio>
using namespace std;
long long int c,pp,ok,nrn,s,p,aux;
int calcul(){ 
	s=0;
	 while(c!=0){
	  c/=5;
	  s+=c;
	 }
}
int main(){
	freopen("fact.in","r",stdin);
	freopen("fact.out","w",stdout);
	scanf("%lld",&p);
	aux=p;
	if(aux==0)
		printf("%d",1);
	else{
		if(aux<0)
			printf("%d",-1);
		else{
	while(aux>5)
		aux/=5;
	if(aux%5==0)
		printf("%d",-1);
	else{
	
	c=5*p;
	aux=c;
	calcul();
	if(s<p){
		c=aux+5;
		while(s!=p){
			aux=c;
			calcul();
			if(s!=p)
				c=aux+5;
		}
		printf("%lld",aux);
	}
	else{
		if(s>p){
			c=aux-5;
		while(s!=p){
			aux=c;
			calcul();
			if(s!=p)
				c=aux-5;
		}
		printf("%lld%",aux);
		}
		else{
			printf("%lld",aux);
		}
	}
	}
	}
	}
	return 0;
}