Cod sursa(job #2303944)

Utilizator ImbuzanRaduImbuzan Radu ImbuzanRadu Data 17 decembrie 2018 11:52:36
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int solve(int val)
{
    int p = 5, cont = 0;
    while(p <= val)
    {
        cont += (val / p);
        p *= 5;
    }
    return cont;
}

int main()
{
    int p, i = 1;
    int nrCifreZero = 0;

    f>>p;
    if(p == 0)
        g<<1;
    else
    {
        while(solve(i) < p)
        {
            i++;
        }
        g<<i;
    }

    return 0;
}