Cod sursa(job #2853045)

Utilizator amcbnCiobanu Andrei Mihai amcbn Data 19 februarie 2022 20:20:06
Problema Factorial Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
/// [A][M][C][B][N] ///
#include <bits/stdc++.h>
using namespace std;
const int mod = 9973;
const int inf = 0x3f3f3f3f;
const char sp = ' ', nl = '\n';
ifstream fin("fact.in");
ofstream fout("fact.out");

int fn(int n) { return n ? n / 5 + fn(n / 5) : 0; }

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    fin >> n;
    int st = 1, dr = 1e9, ans = 0;
    while (st <= dr) {
        int mid = (st + dr) / 2;
        if (fn(mid) >= n)
            ans = mid, dr = mid - 1;
        else
            st = mid + 1;
    }
    fout << ans;
}