Cod sursa(job #2690122)

Utilizator PopescuMihneaPopescu Mihnea-Valentin PopescuMihnea Data 23 decembrie 2020 01:01:25
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("fact.in");
ofstream g ("fact.out");
unsigned long long P,x,nr0,k;
int main()
{
    f>>P;
    if (P==0)
        g<<1;
    else
    {
        while (nr0<P)
        {
            nr0=0;
            x+=5;
            k=5;
            while(k<=x)
            {
                nr0+=x/k;
                k*=5;
            }
        }
        if (nr0==P)
            g<<x;
        else
            g<<-1;
        }

}