Pagini recente » Cod sursa (job #199024) | Borderou de evaluare (job #103677) | Cod sursa (job #203708) | Cod sursa (job #2840566) | Cod sursa (job #1283192)
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int n,p;
void citire()
{
in >> p;
}
int nrz(int m)
{
int nr=0,div=5;
while(m/div!=0){
nr= nr+ m/div;
div=div*5;
}
return nr;
}
int cautare(int p)
{
int st=1,dr=INT_MAX,zero,m,copie;
m=st+(dr-st)/2;
while(st<dr)
{
zero=nrz(m);
if(zero==p)
{
return m;
}
else if(zero<p)
{
st=m-1;
m=st+(dr-st)/2;
}
else{
dr =m+1;
m=st+(dr-st)/2;
}
}
return -1;
}
int main()
{
citire();
out << cautare(p);
return 0;
}
/*
void cautare(int x)
{
int poz=1, pas=1<<21;
while (pas>>=1)
{
if (poz+pas<=n && a[poz+pas]<=x) poz+=pas;
}
if (a[poz]==x) return poz;
return -1;
m=st+ (dr-st)/2;
}
*/