Cod sursa(job #3157189)
Utilizator | Data | 14 octombrie 2023 16:29:13 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int n, nr, mij, st, dr, ok=0, x, t;
fin>>n;
dr=n*6;
st=0;
if(n==0)fout<<1;
else{
while(st<=dr){
mij=(dr+st)/2;
x=0;
nr=mij;
while(nr){
x+=nr/5;
nr=nr/5;
}
if(x>=n){ok=1; t=mij; dr=mij-1;}
else st=mij+1;
}
if(ok==0)fout<<-1;
else fout<<t;
}
}