Cod sursa(job #241618)

Utilizator f.v.antonFlavius Anton f.v.anton Data 10 ianuarie 2009 15:21:47
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream.h>
#include <iostream.h>
#include <math.h>
int main()
{
	long long int p,crt,zerouri=0,i,k;
	fstream f,g;
	f.open("fact.in",ios::in);
	f>>p;
	f.close();
	g.open("fact.out",ios::out);
	crt=5;
	while(zerouri<p)
	{       k=crt;
		while(k%5==0)
		{	zerouri++;
			k/=5;
		}
		crt+=5;
	}
	if(zerouri==p)
		g<<crt-5;
	else
		g<<-1;
	g.close();
	return 0;
}