Cod sursa(job #261620)

Utilizator ShootMeBistriceanu Andrei ShootMe Data 18 februarie 2009 16:23:49
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

long P;
int *a = new int[100];

int main()
{
	freopen ("fact.in","r",stdin);  
	freopen ("fact.out","w",stdout);
	scanf("%ld",&P);  
	
	long BigGuess = 1;

	if (BigGuess == 0)
	{
		printf("%ld\n",1);
		return 0;
	}
	else
	{
		long val = 1;
		long counter = 0;
		bool done = false;
		long reached = 0;
		long NoOf5 = 0;
		while (NoOf5 < P)
		{
			reached += 5;
			long aux = reached;
			while (aux % 5 == 0)
			{
				aux = aux / 5;
				NoOf5 += 1;
			}
		}

		printf("%ld\n",reached);
	}
	return 0;
}