Cod sursa(job #2303943)

Utilizator ImbuzanRaduImbuzan Radu ImbuzanRadu Data 17 decembrie 2018 11:51:48
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.42 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;

    while(solve(i) < p)
    {
        i++;
    }
    g<<i;
    return 0;
}