Cod sursa(job #2609328)

Utilizator dumibBogdan Dumitrescu dumib Data 2 mai 2020 13:50:37
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda igorj_mentorat1 Marime 0.8 kb
#include <bits/stdc++.h>

using namespace std;

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

int cer,n,x,cinci,i,j,pas;
map <int,int> ok;

void fcinci()
{
    while(x % 5 == 0)
    {
        ++ cinci;
        x /= 5;
    }
}
int main()
{
    f >> cer;
    if(!cer)
    {
        g << 1;
        return 0;
    }
    n = 1e4;
    for(i = 5; i <= n; i *= 5)
    {
        ++ pas;
        j = 1;
        while(i * j <= n)
        {
            ok[i * j] = pas;
            ++ j;
        }
    }
    i = 5;
    while(1)
    {
        cinci += ok[i];
        if(cinci >= cer)
        {
            if(cinci == cer)
            {
                g << i;
                return 0;
            }
            g << -1;
            return 0;
        }
        i += 5;
    }
}