Cod sursa(job #668714)

Utilizator Andrei.XweCobzaru Adrian-Andrei Andrei.Xwe Data 25 ianuarie 2012 15:39:05
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
using namespace std;
#include<fstream>
int main()
{
	long long N,P,i,nr=0,a;
	ifstream fcin("fact.in");
	ofstream fcout("fact.out");
	fcin>>P;
	if (P>0)
		fcout<<-1;
	else
		if(P==0)
			fcout<<1;
		else
		{
			for(i=5;nr<P;i+=5)
			{
				a=i;
				while (a%5==0)
				{
					a/=5;
					if(nr<P)
						nr++;
				}
			}
			fcout<<i-5;
		}
	fcin.close();
	fcout.close();
	return 0;
}