/**
 *    author:  tourist
 *    created: 04.11.2025 20:10:25
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  const int N = 2010;
  vector f(N, vector<double>(N));
  f[0][0] = 0;
  for (int i = 1; i < N; i++) {
    f[i][0] = 0.5 * i;
    f[i][i] = i;
    for (int j = 1; j < i; j++) {
      //   j   * (withdraw + roll)
      // (i-j) * roll
      // sum_{x=0..1} max(f[i - 1][j - 1] + 1, f[i - 1][j] + x)
      auto d = f[i - 1][j] - f[i - 1][j - 1];
      f[i][j] = f[i - 1][j - 1] + 1 + 0.5 * d * d;
    }
  }
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k, d;
    cin >> n >> k >> d;
    // roll
    // (k-1) * (withdraw + roll)
    // (n-k) * roll
    // withdraw
    double ans = (d - 1) * 0.5 * n + f[n - 1][k - 1] + 1;
    cout << fixed << setprecision(17) << ans << '\n';
  }
  return 0;
}
