Pagini recente » Cod sursa (job #3000132) | Cod sursa (job #592943) | Cod sursa (job #2636397) | Cod sursa (job #909739) | Cod sursa (job #1919427)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
const int oo = 2000000000;
int P;
int sol = oo + 1;
bool Works(int n){
int zr = 0;
while(n){
zr += n / 5;
n /= 5;
}
if(zr >= P)
return 1;
return 0;
}
void BinarySearch(int left, int right){
int mid;
while(left <= right){
mid = (left + right) / 2;
if(Works(mid)){
sol = mid;
right = mid - 1;
}
else
left = mid + 1;
}
}
int main(){
in >> P;
BinarySearch(0, oo);
if(sol == oo + 1)
out << -1 << "\n";
else
out << sol << "\n";
return 0;
}