```#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

// E[x] = x + 2 * (1-x) * 2x + ...
// want to find p(crit)
// p(crit) = p(crit | 0 attacks missed already) * p(0 attacks missed) + ...
// = x * 1 + 2 x * (1-x) + 3 * x * (1-x) * (1-2x) +

// P[x] = E[x] where x == 1 if i make shot, x == 0 if i dont.
// E[x] = E[ E[x | given last k shots not made] ]
//		= sum P[x | given last k shots not made] * P[last k shots not made]
// E(n) = x * (1 + E(n-1)) + (1-x) * 2x * (1 + E(n-2)) + ...

int round3(ld p) {
return int(1000*p+0.5);
}

int main() {
ios::sync_with_stdio(0);
map<int, pair<ld, ld>> rev;
vector<pair<ld, ld>> f({{0,0}});
for (ld p = 1e-4; p < 1; p += 1e-4) {
ld x = p, pmiss = 1, tot = 0;
vector<ld> E({0});
for (int i = 1; i <= 5000; i++) {
E.push_back(0);
ld pmiss = 1;
for (int j = 1; j <= i; j++) {
E[i] += j * p * pmiss * (1 + E[i-j]);
pmiss *= (1 - j * p);
if (j+1 <= i && (j+1) * p > 1) {
E[i] += pmiss * (1 + E[i-j-1]);
break;
}
}
}
f.push_back({E[5000]/5000, p});
}

map<int, int> ans;
for (int i = 1; i < 1000; i++) {
auto it = lower_bound(f.begin(), f.end(), pair<ld, ld>{i/1000.0 - 1e-4, 0});
ld p = it->second;
p += (++it)->second;
//cerr << i << " " << p/2 << endl;
ans[i] = round3(p/2);
}

ld p;
while (cin >> p) {
cout << "0." << setfill('0') << setw(3) << ans[round3(p)] << endl;
}
return 0;
}```