Cod sursa(job #3219193)
Utilizator | Data | 30 martie 2024 13:19:20 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
int fact(long long n){
int ctr=0;
while(n>=5){
ctr+=n/5;
n/=5;
}
return ctr;
}
int main()
{
int p;
cin>>p;
long long st=1, dr=1e9, rez = dr+1;
while(st<=dr){
long long m= (st+dr)/2;
if(fact(m)>=p){
dr=m-1;
rez=m;
}
else{
st=m+1;
}
}
cout<<rez;
return 0;
}