Cod sursa(job #444073)

Utilizator nopiulianGavrila Iulian nopiulian Data 19 aprilie 2010 12:11:00
Problema Factorial Scor 0
Compilator cpp Status done
Runda Tema 10D #1 Marime 0.38 kb
include<iostream.h>
#include<fstream.h>

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

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

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

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

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

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

	return 0;
}