Cod sursa(job #3280942)

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

using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.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)
    {
        //cout<<nrzero(i)<<'\n';
        if(nrzero(i) == P){
            gasit = i;
            break;
        }
        if(nrzero(i) > P){
            break;
        }
        i++;
    }
    cout<<gasit;
}