Cod sursa(job #2548958)

Utilizator alexevladgabrielAlexe Vlad alexevladgabriel Data 17 februarie 2020 10:40:32
Problema Factorial Scor 35
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin ("fact.in");
ofstream fout ("fact.out");

int x,y;
int main()
{
    int p,nrz;
    fin>>p;
    nrz=0; x=5;
    while(nrz<p)
    {
        y=x;
        while(y%5==0)
        {
            nrz++;
            y/=5;
        }
        x=x+5;
    }
    if(nrz>p)
    {
        fout<<"-1";
    }
    else fout<<x-5;
}