Cod sursa(job #2760377)
Utilizator | Data | 25 iunie 2021 19:25:43 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
using namespace std;
int n,st,dr;
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>n;
st=1;
dr=n*5;
while (st<=dr) {
int mid=(st+dr)/2;
int nr=mid;
int sol=0;
int m=5;
while (nr>=m) {
sol+=nr/m;
m*=5;
}
if (sol>=n) {
dr=mid-1;
}
else {
st=mid+1;
}
}
fout<<st;
return 0;
}