Cod sursa(job #2549861)

Utilizator iustin2004Bolota Iustin iustin2004 Data 18 februarie 2020 08:37:58
Problema Factorial Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,i,nrz,x,n;
int main()
{
    fin>>p;
    if(p==0){fout<<1;
    return 0;}
    nrz=0;
    i=5;
    while(nrz<p)
    {
        x=i;
        while(x%5==0)
        {
            nrz++;
            x=x/5;
        }
        i=i+5;
    }
    if(nrz==p)
        fout<<i-5;
    else
        fout<<-1;
    return 0;
}