Cod sursa(job #2378663)
Utilizator | Data | 12 martie 2019 15:32:25 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main(){
long long st=1,dr=1e9,mid,s=0,P,sol=-1;
f>>P;
while(st<=dr){
s=0;
mid=(st+dr)/2;
for(long long i=5; i<=mid; i*=5){
s=s+mid/i;
}
if(s>P){
dr=mid-1;
}
else{
if(s<P){
st=mid+1;
}
else{
dr=mid-1;
sol=mid;
}
}
}
g<<sol;
return 0;
}