#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; // #include // #include // #include // #include // using namespace atcoder; // #include // using mint = atcoder::modint1000000007; // using mint = atcoder::modint998244353; // #include // using Bint = boost::multiprecision::cpp_int; // #include // using Real = boost::multiprecision::number>; // #include // using Rat = boost::rational; typedef long long ll; const ll INF = 1e18; // interactive #define endl "\n" #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define rrep(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define llacumulate(v) accumulate(all(v), 0LL) #define sz(x) (ll)(x).size() #define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper) #define fi first #define se second #define pb push_back #define eb emplace_back #define pob pop_back #define pc __builtin_popcountll const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; using vi = vector; using vd = vector; using vl = vector; using vvl = vector>; using vs = vector; using vp = vector>; using vpc = vector>; using vb = vector; using vvb = vector>; void yn(bool b) { cout << (b ? "Yes" : "No") << endl; } #define yes cout << "Yes" << endl; #define no cout << "No" << endl; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } fast; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } vector> run_length(const string &str) { ll n = str.size(); vector> res; for (ll l = 0; l < n;) { ll r = l + 1; while (r < n && str[l] == str[r]) ++r; res.push_back({str[l], r - l}); l = r; } return res; } template int get_nearest(const vector &v, const S &a) { int x = lower_bound(all(v), a) - v.begin(), n = v.size(); if (x == 0) return 0; if (x == n) return n - 1; if (abs(v[x] - a) < abs(v[x - 1] - a)) return x; else return x - 1; } template vector> prime_factorize(T n) { vector> res; for (ll i = 2; i * i <= n; ++i) { if (n % i != 0) continue; ll cnt = 0; while (n % i == 0) { n /= i; cnt++; } res.emplace_back(i, cnt); } if (n != 1) res.emplace_back(n, 1); return res; } void print() { cout << endl; } template inline void print(const T &x) { cout << x << endl; } template void print(const T &a, const Ts &...b) { cout << a; (cout << ... << (cout << ' ', b)); cout << endl; } template inline void print(const vector &v) { rep(i, v.size()) { if (i != (ll)v.size() - 1) cout << v[i] << " "; else cout << v[i] << endl; } } template inline void print(const vector> &v) { for (auto &&p : v) print(p); } template inline void print(const pair &p) { cout << p.first << " " << p.second << endl; } template inline void print(const vector> &v) { for (auto &&p : v) print(p); } #ifdef LOCAL #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif int main() { ll t; cin >> t; rep(i, t) { double p; ll k; cin >> p >> k; double ans = 0, now = 1; rep(j, 1, k + 1) { if (j == k) ans += now * j; else ans += now * p * j; now = now - now * p; } print(ans); } }