Pagini recente » Cod sursa (job #2238945) | Cod sursa (job #578328) | Cod sursa (job #2135945) | Cod sursa (job #185909) | Cod sursa (job #2009832)
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e6;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
ll p,l,r,mid;
int check(ll fct)
{
ll i,cnt=0;
for(i=5;fct/i>=1;i*=5)cnt+=fct/i;
if(cnt>=p)return 1;
return 0;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
cin>>p;
l=0,r=2e9;
while(l<=r)
{
mid=(l+r)/2;
if(check(mid))r=mid-1;
else l=mid+1;
}
if(check(r+1))cout<<r+1<<endl;
else cout<<-1<<endl;
return 0;
}