Pagini recente » Cod sursa (job #2980504) | Cod sursa (job #2457334) | Cod sursa (job #278627) | Cod sursa (job #2425539) | Cod sursa (job #2444398)
#include <fstream>
using namespace std;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int m,N=1000000000;
int numarZero(int n){
int s=0;
if(n==0) return 1;
for(long long i=5;n/i>=1;i*=5)
s+=n/i;
return s;
}
int cautBinara(int p){
int s=0,d=N,z;
while(s<=d){
m=( s + d ) / 2;
z = numarZero(m);
if(p == z) {
int x=m;
while(numarZero(x) == z)
x--;
return x+1;}
if(p > z)
{
s = m + 1;
}
if(p < z)
{
d = m - 1;
}
}
}
int main ()
{
long long P,auxP=0,i=1,N;
fin >> P;
fout<<cautBinara(P);
}