Cod sursa(job #631667)

Utilizator galeaolyGalea Olimpiu galeaoly Data 9 noiembrie 2011 14:20:42
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>

using namespace std;

int main()
{
   int p,ok=0,n,fives=0,pp;
   fstream in("fact.in",ios::in);
   fstream out("fact.out",ios::out);
	 in>>p;

	 for(n=1;fives<p;n++)
	 {
		 pp=5*n;

		 while (pp%5==0) { fives++; pp=pp/5;};

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

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

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

    return 0;
}