Cod sursa(job #529080)

Utilizator cosminvdpruna stefan cosminvd Data 4 februarie 2011 10:48:20
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<fstream>
using namespace std;
long p,d5,n;
int main()
{
	ifstream f("fact.in");
	ofstream g("fact.out");
	f>>p;
	if(p==0)
	
		g<<1;
	
	else
		if(p<0)
			g<<-1;
		else
			
	{
	n=2;
	while(d5<p)
	{
        long m=n;
	if(m%5==0)
		while(m&&m%5==0)
		{
			m/=5;
			d5++;
		}
			n++;
	}
	
			g<<n-1<<" ";
	}
			return 0;
}