Cod sursa(job #2792763)

Utilizator christalknightChristian Micea christalknight Data 2 noiembrie 2021 11:59:20
Problema Factorial Scor 35
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <fstream>

using namespace std;

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


int main()
{
    unsigned long long N = 1, P, i, boolean_var = 0;
    fin>>P;
    for(i = 1; P > 0; i += 5){
        N = i;
        while(N % 5 == 0){
            N /= 5;
            P--;
            }
        if(i == 1)
            i--;
        if(P < 0){
            boolean_var = 1;
            break;
            }
        else if(!P)
            break;
        }
    if(boolean_var)
        fout<<-1;
    else fout<<i;
}