#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include #include #include #include using namespace std; // #define getchar getchar_unlocked bool dot; int in() { int n, c; while ((c = getchar()) < '0') { assert(c != EOF); } n = c - '0'; while ((c = getchar()) >= '0') { n = n * 10 + c - '0'; } if (c == '.') { dot = true; } return n; } const int H = 17; const int N = 1 << H; double lg[N]; double lgt[N]; void dfs(int k, double l, double r) { if (k < N) { lg[k] = log((l + r) / 2); dfs(k * 2 + 0, l, (l + r) / 2); dfs(k * 2 + 1, (l + r) / 2, r); } } int main() { const double L = 0; const double R = log(10); const double LL = -1e100; const double RR = log(R); dfs(1, L, R); for (int i = 1; i <= 100000; i++) { lgt[i] = log(0.0001 * i); } int m = in(); while (m--) { int a = in(); int b = in(); int c = in(); int d = dot ? in() : 0; double t = c + 1e-4 * d; if (b == 0) { printf("%.12f\n", pow(t, 1.0 / a)); continue; } if (a == 0) { printf("%.12f\n", exp(pow(t, 1.0 / b))); continue; } double ok = R; double ng = L; double logT = lgt[c * 10000 + d]; double logL = LL; double logR = RR; int k = 1; for (int ii = 0; ii < H; ii++) { double mid = (ok + ng) / 2; if (a * mid + b * lg[k] >= logT) { logR = lg[k]; k = k * 2 + 0; ok = mid; } else { logL = lg[k]; k = k * 2 + 1; ng = mid; } } for (int ii = H; (ok - ng) > 0.9e-9; ii++) { double mid = (ok + ng) / 2; double logM = (logL + logR) / 2; if (a * mid + b * logM >= logT) { ok = mid; logR = logM; } else { ng = mid; logL = logM; } } printf("%.12f\n", exp(ok)); } }