Cod sursa(job #582764)

Utilizator stef93Stefan Gilca stef93 Data 15 aprilie 2011 21:00:02
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<iostream>
#include<fstream>
using namespace std;

ifstream in("fact.in");
ofstream out("fact.out");

int main()
{
	int p,ok=0,n,cinci=0,pp;
	in>>p;

	for(n=1;ok==0 && n>0;n++)
	{
		pp=n;
		while(pp%5==0){
			if (pp%5==0) { cinci++; pp=pp/5;}
			}

		if(cinci>=p)
			ok=n;
	}

	if(cinci != p) out<<-1;
	else out<<ok;

	out.close();
	in.close();

	return 0;
}