#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t T; cin >> T; for (int64_t t = 0; t < T; t++) { long double p; int64_t k; cin >> p >> k; map mp; auto f = [&](auto &&g, int64_t x) -> long double { if (mp.find(x) != mp.end()) { return mp[x]; } if (k <= x) { return mp[x] = 0; } long double ret = 1 + (1 - p) * g(g, x + 1); return mp[x] = ret; }; cout << fixed << setprecision(20) << f(f, 0) << endl; } return 0; }