Cod sursa(job #2785388)

Utilizator mihai002016Zaharia Teodor Mihai mihai002016 Data 18 octombrie 2021 17:11:44
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb

#include <fstream>
using namespace std;
ifstream fin("a.in");
ofstream fout("a.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;
}