Cod sursa(job #3137218)

Utilizator cattyAninisCatrinel catty Data 11 iunie 2023 17:41:01
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <bits/stdc++.h>
#define L long long
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
L x,i,c,t;
int main()
{
    in>>x;
    if(x==0)
    {
        out<<1;
        return 0;
    }
    for(i=1;i;++i)
    {
        ++t;
        c=i;
        while(c%5==0)
        c/=5,++t;
        if(t==x)
        {
            out<<i*5;
            return 0;
        }
        else if(t>x)
        {
            out<<-1;
            return 0;
        }
    }
}