Cod sursa(job #448782)

Utilizator ms-ninjacristescu liviu ms-ninja Data 4 mai 2010 18:53:17
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <fstream>

using namespace std;

int main()
{
	long n, aux, s, exp;
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	
	
	fin>>n;
	
	
	if(n==0)
	{fout<<"1";return 0;}
	
	
	int ok=0;
	
	
	s=4*n;
	
	
	while(ok==0)
	{
		aux=s;
		exp=0;
		while(aux)
		{
			exp+=aux/5;
			aux=aux/5;
		}
		if(exp==n)
			ok=1;
		else
			if (exp<n)s++;
			else
			{
				fout<<"-1";
				return 0;
			}
			
	}
	
	fout<<s;
	
	return 0;
}