Cod sursa(job #1268640)

Utilizator sherban26FMI Mateescu Serban-Corneliu sherban26 Data 21 noiembrie 2014 10:50:00
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin ("fact.in");
ofstream fout ("fact.out");

long _div(long x)
{
    long d = 5, rez = 0;

    while (x / d)
    {
        rez += x / d;
        d *= 5;
    }

    return rez;
}

int main()
{
    long aux, n, x = 0, f = 5;

    fin >> n;

    if (n == 0)
        fout << 1;
    else
    {
        while (true)
        {
            if (_div(f) == n)
            {
                fout << f;
                break;
            }
            f += 5;
        }
    }

    return 0;
}