Cod sursa(job #2501539)

Utilizator cacior_mariusCacior Marius-Valentin cacior_marius Data 29 noiembrie 2019 20:29:04
Problema Factorial Scor 35
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
	int n, p=0, i=0, x;
	fin >> n;
	if(n==0)
	{
		fout<<1;
		return 0;
	}
	while (i!=n)
	{
		p+=5;
		x=p;
		while (x%5==0)
		{
			x/=5;
			i++;
		}
	}
	if(i>n)
		fout<<-1;
	else
		fout<<p;
	return 0;
}