Cod sursa(job #261625)

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

using namespace std;
long P;

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

	if (P == 0)
	{
		printf("%ld\n",1);
		return 0;
	}
	else
	{
		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;
}