Cod sursa(job #3269511)

Utilizator anon2718281828Iasmina Matei anon2718281828 Data 19 ianuarie 2025 14:14:18
Problema Factorial Scor 80
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <bits/stdc++.h>
#define int int64_t

using namespace std;

int32_t main() {
    ifstream in("fact.in");
    ofstream out("fact.out");
    
    int p;
    in >> p;

    int sol;
    if (p == 0) sol = 1;
    else {
       int k = 5;
       int curr0s = 0;
       while (true) {
        int aux = k;
        while (aux % 5 == 0 && aux != 0) {
            aux /= 5;
            curr0s++;
        }
        if (curr0s == p) {sol = k; break;}
        else if (curr0s > p) {sol = -1; break;}
        k += 5;
       }
    }
    
    out << sol;
    return 0;
}