Cod sursa(job #3195536)

Utilizator verde.cristian2005Verde Flaviu-Cristian verde.cristian2005 Data 21 ianuarie 2024 10:27:50
Problema Factorial Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <bits/stdc++.h>
using namespace std;

#ifndef ACASA
    ifstream in("fact.in");
    ofstream out("fact.out");
    #define cin in
    #define cout out
#endif

int main()
{
#ifdef ACASA
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    int p, n = 5;
    cin >> p;
    if(p == 0)
    {
        cout << 1;
        return 0;
    }
    while(p > 0)
    {
        int cn = n;
        while(cn % 5 == 0)
        {
            p--;
            cn /= 5;
        }
        n += 5;
    }
    if(p < 0)
        cout << -1;
    else
        cout << n - 5;
    return 0;
}