Cod sursa(job #2698815)

Utilizator gasparrobert95Gaspar Robert Andrei gasparrobert95 Data 23 ianuarie 2021 09:50:28
Problema Factorial Scor 35
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
ll n;

int main() {
    fin >> n;
    if (n == 0) {
        fout << 1;
        return 0;
    }
    ll z = 1, i = 5;
    while (z < n) {
        i += 5;
        ll ci = i;
        while (ci % 5 == 0)
            ci /= 5, ++z;
    }
    if (z == n)
        fout << i;
    else
        fout << -1;
    return 0;
}