Cod sursa(job #2851420)

Utilizator alexandru.ciorneiAlexandru-Stefan Ciornei alexandru.ciornei Data 18 februarie 2022 17:00:44
Problema Factorial Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>

using namespace std;

int main() {
    ifstream fin("fact.in");
    ofstream fout("fact.out");

    int p = 0;
    fin >> p;

    if (p == 0) {
        fout << 1;
    } else {
        unsigned long long int n = 5;
        int nrzero = 1;
        while (nrzero < p) {
            n += 5;
            unsigned long long int aux = n;
            while (aux % 5 == 0) {
                nrzero++;
                aux /= 5;
            }
        }
        fout << n;
    }

    return 0;
}