Cod sursa(job #546278)

Utilizator Kaara333Stircu Daniela Kaara333 Data 4 martie 2011 18:46:05
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<fstream>
using namespace std;
int main()
{
	long long P,x,a=0,cx;
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	fin>>P;
	if(P==0)
		fout<<1;
	else
	{
		for(x=5; x<=100000000; x=x+5)
		{
			cx=x;
			while(cx%5==0)
			{
				a++;
				cx/=5;
			}	
			if(a>=P)
				break;
		}
		if(a==P)
			fout<<x;
		else
			fout<<-1;
	}
	fin.close();
	fout.close();
	return 0;
}