Cod sursa(job #2064032)

Utilizator cyg_ionutStan Ionut Gabriel cyg_ionut Data 11 noiembrie 2017 18:39:05
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int n;

int zero(int x) {
    int ans = 0;
    while (x / 5 > 0) {
        ans = ans + x / 5;
        x = x / 5; }
    return ans; }

int main() {
    freopen("fact.in", "r", stdin);
    freopen("fact.out", "w", stdout);

    scanf("%d", &n);
    int ans = 0;
    for (i64 bit = 1 << 30; bit > 0; bit = bit / 2)
        if (zero(bit + ans) < n)
            ans = ans + bit;
    printf("%d", ans + 1);
    return 0; }