Cod sursa(job #2785340)

Utilizator mihai002016Zaharia Teodor Mihai mihai002016 Data 18 octombrie 2021 16:32:47
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.95 kb

#include <fstream>
using namespace std;
ifstream fin("a.in");
ofstream fout("a.out");
class Problema
{
    int p;
public:
    Problema(void)
    {
        p = 0;
    }
    Problema(int x)
    {
        p = x;
    }
    void Rezolvare()
    {
        int p2 = 0, p5 = 0;
        int x = 0,y;
        while (p2 < p || p5 < p)
        {
            if ((x + 1) % 2 == 0) {
                y = x+1;
                while (y % 2 == 0) {
                    y = y / 2;
                    p2++;
                }
            }
            if ((x + 1) % 5 == 0)
            {
                y = x + 1;
                while (y % 5 == 0) {
                    y = y / 5;
                    p5++;
                }
            }
            x++;
        }
        if (x == 0)
            fout << 1;
        else
            fout << x;
    }
};

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