Cod sursa(job #1889267)

Utilizator mesbotMeszaros Botond mesbot Data 22 februarie 2017 17:32:59
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>

long int p, n, c, num;

int main()
{
    std::ifstream f("fact.in");
    std::ofstream g("fact.out");
    f>>p;

    if(p == 0)
        g<<1;
    else
    {
        n = 4*p;
        do{
            num = n;
            c = 0;
            while(num != 0)
                num /= 5, c += num;

            n++;
        }while(c < p);

        if(c == p) g<<--n;
        else g<<-1;
    }

    return 0;
}