Pagini recente » Borderou de evaluare (job #454411) | Borderou de evaluare (job #1803255) | Borderou de evaluare (job #910159) | Borderou de evaluare (job #904045) | Cod sursa (job #1999194)
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int P;
scanf("%lld",&P);
if(P==0) return printf("1\n"),0;
int st=1,dr=INT_MAX;
while(st<=dr){
int mij=(st+dr)>>1,x=mij,no=0;
while(x){
no+=x/5;
x/=5;
}
if(no>=P) dr=mij-1;
else st=mij+1;
}
int x=st,no=0;
while(x){
no+=x/5;
x/=5;
}
if(no==P) printf("%d\n",st);
else printf("-1\n");
return 0;
}