Cod sursa(job #2644941)
| Utilizator | Data | 26 august 2020 14:53:13 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
/*
Username : moondancer
Name : Moon Dancer
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin>>n;
int l=1,r=2e18;
int ans=0;
while(l<=r){
int mid=(l+r)/2;
int x=mid;
int s=0;
while(x){
s+=x/5;
x/=5;
}
if(s>=n){
ans=mid;
r=mid-1;
}
else{
l=mid+1;
}
}
int t=0;
int xx=ans;
while(ans){
t+=ans/5;
ans/=5;
}
if(t==n) cout<<xx;
else cout<<-1;
return 0;
}