#include <bits/stdc++.h>
using namespace std;

template <typename T> void set_min(T& a, const T& b){
	if(b < a) a = b;
}
template <typename T> void set_max(T& a, const T& b){
	if(b > a) a = b;
}

using ld = long double;

int N = 2000;
int K = 2000;

vector<vector<ld> > dp(N+1, vector<ld>(K+1));
void init(){
	for(int a = 0; a <= N; a++){
		for(int b = 0; b <= K; b++){
			if(a) set_max(dp[a][b], dp[a-1][b]);
			if(b) set_max(dp[a][b], dp[a][b-1]);
			if(a && b){
				ld diff = dp[a-1][b] - dp[a-1][b-1];
				set_max(dp[a][b], dp[a-1][b-1] + (diff * diff + 1) / 2 );
			}
		}
	}	
}

void solve(){
	int N, K, D;
	cin >> N >> K >> D;

	ld ans = ld(D) * ld(N) / 2 + dp[N-1][K-1] + ld(1) / ld(2);
	cout << fixed << setprecision(10);
	cout << ans << '\n';
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	init();
	int T;
	cin >> T;
	while(T--) solve();
}
