Cod sursa(job #3280937)

Utilizator robert.barbu27robert barbu robert.barbu27 Data 27 februarie 2025 20:53:28
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <fstream>

using namespace std;
ifstream cin("numere.in");
ofstream cout("numere.out");
int nrzero(int x)
{
    int nrZeros = 0;
    int prod = 5;
    while (x <= prod)
    {
        nrZeros += x / prod;
        prod = prod * 5;
    }
    return nrZeros;
}
int P;
int main()
{
    cin >> P;
    int i = 1;
    int gasit = -1;
    while (true)
    {
        if(nrzero(i) == P){
            gasit = 1;
            break;
        }
        if(nrzero(i) > P){
            break;
        }
    }
    cout<<gasit;
}