Pagini recente » Cod sursa (job #1259108) | Cod sursa (job #1822857) | Cod sursa (job #2740857) | Cod sursa (job #2921075) | Cod sursa (job #1590455)
#include <stdio.h>
using namespace std;
#define nrmax 100000000;
long long zerofact(int x){
int sol=0;
while(x/5){
if(x/5!=0){
sol = sol + x/5;
x=x/5;
}
}
return sol;
}
int cautbin (int n){
long long st=1;
long long dr=2000000000;
while(st<dr){
long long mij=(st+dr)/2;
if(zerofact(mij)==n)
return mij-mij%5;
else if(zerofact(mij)>n)
dr = mij-1;
else
st = mij+1;
}
return -1;
}
int main(){
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int n;
scanf("%d", &n);
if(n) printf("%d", cautbin(n));
else printf("1");
return 0;
}