Cod sursa(job #3037512)

Utilizator InformatqueAndreea Popa Informatque Data 25 martie 2023 17:51:33
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <fstream>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

typedef long long Int;

Int calculNr(Int P){
    int cnt = 0, i = 0;
    while (cnt < P){
        i++;
        cnt++;
        int x = i;
        while (x % 5 == 0){
            x /= 5;
            cnt++;
        }
    }
    if (cnt == P){
        return 5 * i;
    }
    else {
        return -1;
    }
}

int main()
{
    Int P;
    fin >> P;
    if (P == 0){
        fout << 1;
    }
    else {
        Int n = calculNr(P);
        fout << n;
    }
    
    fin.close();
    fout.close();
    return 0;
}