Cod sursa(job #3184529)

Utilizator cosmin_mihaiDumitru Cosmin cosmin_mihai Data 16 decembrie 2023 10:37:10
Problema Factorial Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
//
// Created by Cosmin Dumitru on 16.12.2023.
//
#include <fstream>
using namespace std;

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

int nr_zero(int m){
    int nr0=0;
    while(m>=5){
        nr0+=m/5;
        m/=5;
    }
    return nr0;
}

int main(){
    int p;
    fin >> p;
    int st = 0,dr=5e8,rez = 5e8;
    while(st<=dr){
        int m = (st+dr)/2;
        if(nr_zero(m)>=p){
            rez = m;dr = m-1;
        }else{
            st=m+1;
        }
    }
    fout << rez;
    return 0;
}