Cod sursa(job #2067358)

Utilizator StepHoria Stefan Step Data 16 noiembrie 2017 11:49:31
Problema Factorial Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 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;
	}
	if (r==0)
		return -1;
	else return r+1;
}

int main()
{
	int i,n;
	f>>n;
	g<<caut(n);
    return 0;
}