Cod sursa(job #2731981)

Utilizator Sho10Andrei Alexandru Sho10 Data 28 martie 2021 16:31:38
Problema Factorial Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll cnt;
ll check(ll x){
ll res=0;
ll val=5;
while(val<=x){
    res+=x/val;
    val*=5;
}
return (res>=cnt);
}
int32_t main(){
CODE_START;
ifstream cin("fact.in");
ofstream cout("fact.out");
cin>>cnt;
ll l=1,r=1e18,res=0;
while(l<=r){
    ll mid=(l+r)/2;
    if(check(mid)){
        r=mid-1;
        res=mid;
    }else l=mid+1;
}
cout<<res<<endl;
}