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