Cod sursa(job #2785389)

Utilizator mihai002016Zaharia Teodor Mihai mihai002016 Data 18 octombrie 2021 17:12:09
Problema Factorial Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb

#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");

int main()
{
    int p;
    fin >> p;
    int p5 = 0;
    int x = 0, y;
    while (p5 < p)
    {
        x = x + 5;
        y = x;
        while (y % 5 == 0)
        {
            p5++;
            y = y / 5;
        }
    }
    if (p == 0)
        fout << 1;
    else
        if (p5 > p)
            fout << -1;
        else
            fout << x;
}