#pragma GCC optimize ("O3") #pragma GCC optimize ("fast-math") #pragma GCC target ("avx") #include using namespace std; const int N = 1 << 16; const double dx = log(10) / N; const double ldx = log(log(10)) - 16 * log(2); double lg[(1 << 17) + 1]; namespace fastio { #define getchar getchar_unlocked #define putchar putchar_unlocked bool dot; int readInt() { int n, c; while ((c = getchar()) < '0') { assert(c != EOF); } n = c - '0'; while ((c = getchar()) >= '0') { n = n * 10 + c - '0'; } dot = c == '.'; return n; } void printDouble(double x) { int a = x; int b = (x - a) * 1e9; int d[11]; int i = 0; do { d[i++] = a % 10; a /= 10; } while (a > 0); while (i > 0) { putchar(d[--i] + '0'); } putchar('.'); while (i < 9) { d[i++] = b % 10; b /= 10; } while (i > 0) { putchar(d[--i] + '0'); } putchar('\n'); } } double solve(int a, int b, int c, int d) { double lt = lg[c * 10000 + d] - ldx - 4 * log(10); if (b == 0) { return exp(lt / a); } if (a == 0) { return exp(exp(lt / b)); } int l = 0; int r = N; while (r - l > 1) { int mid = (l + r) / 2; (a * mid * dx + b * lg[mid] >= lt ? r : l) = mid; } double s = (lg[r] - lg[l]) / dx; return exp((lt + s * b * l * dx - lg[l] * b) / (s * b + a)); } int main() { for (int i = 0; i <= 1 << 17; i++) { lg[i] = log(i) + ldx; } int m = fastio::readInt(); for (int i = 0; i < m; i++) { int a = fastio::readInt(); int b = fastio::readInt(); int c = fastio::readInt(); int d = fastio::dot ? fastio::readInt() : 0; fastio::printDouble(solve(a, b, c, d)); } }