Cod sursa(job #2149345)
Utilizator | Data | 2 martie 2018 15:31:22 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
#include <climits>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,n,ex,sol;
long long mij,ex5,ls=1,ld=INT_MAX-2;
int main()
{
f>>p;
while(ls<=ld)
{
mij=(ls+ld)/2;
ex=5;
ex5=0;
while(ex<=mij)
{
ex5+=mij/ex;
ex*=5;
}
if(ex5>=p)
{
ld=mij-1;
sol=mij;
}
else ls=mij+1;
}
g<<sol;
return 0;
}