Cod sursa(job #2611184)

Utilizator ParALIParaschiv Alexandru-Andrei ParALI Data 6 mai 2020 15:48:34
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
    int i, p, s, P, n=1;
    bool ok = 1;
    f >> P;

    while(ok)
    {
        p=5;
        s=0;
        while(p <= n)
        {s += n / p;
        p *= 5;}

        if(s==P)
            ok=0;
        else
            n++;
    }
    g << n;

    return 0;
}