Cod sursa(job #2183051)

Utilizator buzauioanaBuzau Ioana buzauioana Data 22 martie 2018 19:35:28
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nrz(int x)
{
    int q=5,k=0;
    while(q<=x)
    {
        k+=x/q;
        q=q*5;
    }
    return k;
}
int main()
{
    int p,i=0;
    fin>>p;
    while(nrz(i)<p)
        i+=5;
    if(nrz(i)>p)
        fout<<"-1";
    else
    fout<<i<<" ";
    return 0;
}