Pagini recente » Cod sursa (job #2965133) | Cod sursa (job #3240684) | Cod sursa (job #399816) | Cod sursa (job #2436248) | Cod sursa (job #2210335)
#include <iostream>
#include <cstdio>
using namespace std;
int zero(int n) {
int p=5,s=0;
while(n/p!=0) {
s+=n/p;
p*=5;
}
return s;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int n,st,dr,mij,elem=-1,z;
scanf("%d",&n);
if(n==0) {
cout<<1;
return 0;
}
st=0;
dr=5*n;
while(st<=dr) {
mij=(st+dr)/2;
z=zero(mij);
if(z>n)
dr=mij-1;
else {
if(z<n)
st=mij+1;
else {
elem=mij;
dr=mij-1;
}
}
}
cout<<elem;
return 0;
}