Cod sursa(job #1156522)

Utilizator ivyleague24Popescu Ion ivyleague24 Data 27 martie 2014 19:05:14
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<iostream>
#include<fstream>
using namespace std;
int k;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int m)
{
	int div,s=0;
	div=m;
	while(div)
	{
		div=div/5;
		s=s+div;
	}
	return s;
}
int cauta(int li, int ls)
{
	int m;
	if(li==ls)
		return -1;
	m=(li+ls)/2;
	if(zero(m)==k)
		return m;
	else
		if(zero(m)<k)
			return cauta(m+1,ls);
		else
			return cauta(li,m-1);
	
}
int main()
{
  cout<<"k=";
  cin>>k;
  if(k==0)
	cout<<1;
  else
  {
  cout<<cauta(0,k*10);
  }
}