Cod sursa(job #3326236)

Utilizator Cristian.p08Popescu Cristian Cristian.p08 Data 27 noiembrie 2025 20:03:00
Problema Factorial Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
    int P,k=5,S=0,k2;
    fin>>P;
    if(P==0)
    {
        fout<<1;
    }
    else
    {
    while(S<P)
    {
        k2=k;
        while(k2%5==0)
        {
            S=S+1;
            k2=k2/5;

        }
        k=k+5;

    }
    if(S==P)
    {
        fout<<k-5;
    }
    else
    {
        fout<<-1;
    }
    }
    return 0;
}