Cod sursa(job #2785381)

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

#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
class Problema
{
    int p;
public:
    Problema(void)
    {
        p = 0;
    }
    Problema(int x)
    {
        p = x;
    }
    void Rezolvare()
    {
        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;
    }
};

int main()
{
    int p;
    fin >> p;
    Problema po(p);
    po.Rezolvare();
}