Cod sursa(job #3157179)

Utilizator LilGoat_4109Calin Andrei Cristian LilGoat_4109 Data 14 octombrie 2023 16:12:28
Problema Factorial Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("fact.in");
ofstream out("fact.out");
 
int zero(int x)
{
    int c=0;
    while(x){
        c+=x/5;
        x=x/5;
        }
    return c;
}
int main()
{
    int n;
    in>>n;
    int s=0,d=5*n+1,r=d;
    while(s<=d){
        int mij=(s+d)/2;
        if(zero(mij)>=n){
            r=mij;
            d=mij-1;
        }
        else
            s=mij+1;
    }
    out<<r;
    return 0;
}