Cod sursa(job #428603)

Utilizator dtoniucDaniel Toniuc dtoniuc Data 29 martie 2010 13:35:35
Problema Factorial Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.35 kb
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
	int p,n=0,nr=0;
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	fin>>p;
	if (p==0) fout<<"1";
	else 
	{
		while (p>0)
		{
			n+=5;
			nr=n;
			while (nr%5==0)
			{
				p-=1;
				nr=nr/5;
			}	
		}
		if(p<0) fout<<"-1";
		else fout<<n;
	}
	return 0;
}