Cod sursa(job #2785354)

Utilizator mihai002016Zaharia Teodor Mihai mihai002016 Data 18 octombrie 2021 16:47:59
Problema Factorial Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 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++;
  
            if (x % 5 == 0)
            {
                y = x ;
                while (y % 5 == 0) {
                    y = y / 5;
                    p5++;
                }
            }
        }
        if (p5 > p)
            fout << -1;
        else
            fout << x;
    }
};

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