#include #include #include #include using namespace std; #define getchar getchar_unlocked #define putchar putchar_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; } void out(double x) { static char buf[20]; sprintf(buf, "%.9f", x); for (int i = 0; buf[i] != '\0'; i++) { putchar(buf[i]); } putchar('\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); int m = in(); for (int i = 0; i < N; i++) { lgt[i] = 1e100; } 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) { out(pow(t, 1.0 / a)); continue; } if (a == 0) { out(exp(pow(t, 1.0 / b))); continue; } double l = L; double r = R; double logL = LL; double logR = RR; if (lgt[c * 10000 + d] == 1e100) { lgt[c * 10000 + d] = log(t); } double logT = lgt[c * 10000 + d]; int k = 1; for (int ii = 0; ii < H; ii++) { double mid = (l + r) / 2; if (a * mid + b * lg[k] >= logT) { logR = lg[k]; k = k * 2 + 0; r = mid; } else { logL = lg[k]; k = k * 2 + 1; l = mid; } } double s = (logR - logL) / (r - l); double ans = (logT + s * l * b - logL * b) / (s * b + a); out(exp(ans)); } }