Cod sursa(job #3163101)

Utilizator TomMMMMatei Toma TomMMM Data 30 octombrie 2023 15:47:35
Problema Factorial Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");
int P;
int Put5(int x){
    if(x<5)
        return 0;
    return x/5+Put5(x/5);
}
int verif(int x){
    if(Put5(x)>=P)
        return 1;
    return 0;
}

long det(){
    long L=1,R=500000000,M;
    long sol;
    while(L<=R){
        M=(L+R)/2;
        if(verif(M)){
            sol=M;
            R=M-1;
        }else{
            L=M+1;
        }
    }
    return sol;
}


int main() {
    fin>>P;
    fout<<det();

}