Cod sursa(job #3364658)

Utilizator andrei_brasoveanu7Andrei Octavian andrei_brasoveanu7 Data 8 septembrie 2026 19:27:10
Problema Factorial Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in ("fact.in");
ofstream out ("fact.out");

long long n, f=5, cnt;

int main () {
    in >> n;
    if (n == 0)
    {
        out << 1;
        in.close();
        out.close();
        return 0;
    }
    while (true) {
        long long copie = f;
        while (copie % 5 == 0)
        {
            copie /= 5;
            ++cnt;
        }
        if (cnt == n)
            break;
        f += 5;
    }
    out << f;
    in.close();
    out.close();
    return 0;
}