#include #include #include #include #include #define rep(i,n)for(ll i=0;i, greater > using ll = long long; using ull = unsigned long long; ll mod = 998244353; ll modi = 499122177; const int inf = 1000000000; using namespace std; using namespace atcoder; vector topological_sort(vector>& G, vector& indegree) { ll n = G.size(); vector res; priority_queue, greater> que; for (ll i = 1; i < n; i++) if (indegree[i] == 0) que.push(i); while (!que.empty()) { ll ver = que.top(); que.pop(); res.push_back(ver); for (int i : G[ver]) { indegree[i]--; if (indegree[i] == 0) que.push(i); } } return res; } ll gcd(ll a, ll b) { if (a > b)swap(a, b); while (a > 0) { b %= a; if (a > b)swap(a, b); if (a == b)break; } return b; } bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } bool ing(ll x, ll y, ll h, ll w) { bool a = x < h && y < w; bool b = x >= 0 && y >= 0; return a && b; } void dfs(vector& vis, vector>& G, ll x) { vis[x] = 1; for (ll i : G[x]) { if (vis[i] == 0) { dfs(vis, G, i); } } } int main() { ll t; cin >> t; while (t--) { ll k; double p; cin >> p >> k; double ans = 0; double j = 1; for (ll i = 1; i < k; i++) { double a = pow(1 - p, i - 1) * p; j-= a; ans += a * i; } ans += j * k; cout <