Cod sursa(job #1999192)

Utilizator Vlad3108Tir Vlad Ioan Vlad3108 Data 10 iulie 2017 16:10:59
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <bits/stdc++.h>
using namespace std;
int main(){
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    int P;
    scanf("%d",&P);
    if(P==0) return printf("1\n"),0;
    int st=1,dr=INT_MAX;
    while(st<=dr){
        int mij=(st+dr)>>1,x=mij,no=0;
        while(x){
            no+=x/5;
            x/=5;
        }
        if(no>=P) dr=mij-1;
        else st=mij+1;
    }
    printf("%d\n",st);
    return 0;
}