Cod sursa(job #3174872)

Utilizator mirceamaierean41Mircea Maierean mirceamaierean41 Data 25 noiembrie 2023 10:37:37
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
#include <iostream>

using namespace std;

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

int main()
{
    long long p, i = 0;
    fin >> p;
    while (true)
    {
        i++;
        long long cnt = 0;
        for (long long j = 5; j <= i; j *= 5)
            cnt += i / j;
        if (cnt == p)
        {
            fout << i << '\n';
            return 0;
        }
    }
    return 0;
}