#include <iostream>
#include <vector>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using ld = long double;
using namespace std;
mt19937 rnd(179);
const int MAXN = 2010;
ld dp[MAXN][MAXN];

void solve() {
    int n, k, d;
    cin >> n >> k >> d;
    ld out = dp[n][k] + (d - 1) * 0.5 * n;
    // ld out = dp[n][k];
    cout << out << '\n';
}

signed main() {
    for (int k = 1; k < MAXN; k++) dp[0][k] = 0;
    for (int k = 1; k < MAXN; k++) dp[1][k] = 1;
    for (int n = 0; n < MAXN; n++) dp[n][0] = 0;
    for (int n = 2; n < MAXN; n++) {
        for (int k = 1; k < MAXN; k++) {
            ld dx = dp[n - 1][k - 1] + 1 - dp[n - 1][k];
            if (dx < 0) {
                dp[n][k] = dp[n - 1][k] + 0.5;
            } else if (dx > 1) {
                dp[n][k] = dp[n - 1][k - 1] + 1.0;
            } else {
                dp[n][k] = dx * (dp[n - 1][k - 1] + 1.0) + (1.0 - dx) * dp[n - 1][k] + (0.5 - dx * dx / 2);
            }
        }
    }

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(30);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}