Cod sursa(job #1219989)

Utilizator tudormarcuMarcu Tudor tudormarcu Data 16 august 2014 11:26:44
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main()
{
	unsigned long i = 1, aux = 0;
	long P = 0;
	ifstream f ( "factorial.in" );
	f >> P;
	f.close();

	if ( P > 0 )
	{
		for ( i = 5; P > 0; i += 5 )
		{
			aux = i;

			while ( aux % 5 == 0 )
			{
				P--;
				aux = aux / 5;
			}
		}

		i -= 5;
	}
	else
	{
		i = 1;
	}

	ofstream g ( "factorial.out" );

	if ( P == 0 )	g << i;
	else g << -1;

	g.close();
	return 0;
}