Cod sursa(job #2067365)

Utilizator StepHoria Stefan Step Data 16 noiembrie 2017 11:58:29
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
using namespace std;

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

int nrz (int n)
{
	int nr=0;
	while (n>=5)
	{
		nr+=n/5;;
		n/=5;
	}
	return nr;
}

int caut (int x)
{
	int pas=1<<30,r=0;
	while (pas!=0)
	{
		if (nrz(r+pas)<x)
			r+=pas;
		pas/=2;
	}
	return r+1;
}

int main()
{
	int i,n,x;
	f>>n;
	x=caut(n);
	if (nrz(x)==n)
		g<<x;
	else g<<-1;
    return 0;
}