Cod sursa(job #600886)

Utilizator luckyme91wiz kid luckyme91 Data 4 iulie 2011 00:01:29
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <iostream>
#include <fstream>

using namespace std;

int main () {

ifstream in ("fact.in");
ofstream out ("fact.out");

int n, i, count, temp, p;

in >> n;
count = 0;
p = 1;
for (i = 1; i; i+=p)
{
	temp = i;
	while (temp % 5 == 0)
	{
		temp /= 5;
		count ++;
	}
	if (i == 5)
	p = 5;
	if (count == n)
	{
		out << i;
		break;
	}
	if (count > n)
	{
		out << -1;
		break;
	}
}
return 0;
}