Cod sursa(job #2188454)

Utilizator raulsomesanRaul Somesan raulsomesan Data 27 martie 2018 10:03:26
Problema Factorial Scor 40
Compilator cpp Status done
Runda bpc9 Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream fin("fact.in");
    ofstream fout("fact.out");
    int p;
    fin>>p;
    if(p==0)
        fout<<1;
    else
    {
        int x=0;
        int k=0;
        while(k<=p)
        {
            x=x+5;
            int cx=x;
            while(cx%5==0)
            {
                ++k;
                cx=cx/5;
            }
        }
        if(p%5==0)
            fout<<-1;
        else
            fout<<x-5;
    }
}