#include #include #include #include #include #include #include #define int long long using namespace std; typedef long long ll; long double sqr(long double x) {return x * x;} int Solve() { ll a, b, x; scanf("%lld%lld%lld", &a, &b, &x); if(x * x > a * a + b * b) return 1; if(x <= b) { int ans1 = a / x + 1; int rt1_int = b - sqrt(4ll * x * x - 4ll * (a % x) * (a % x)), ans2 = b - sqrt(4ll * x * x - 4ll * (a % x) * (a % x)) >= 0 ? rt1_int / x + 1 : 0; return ans1 * 2 + ans2; } // x in (b, sqrt(a^2 + b^2)] // x >= 2 * b / sqrt(3) if(3 * x * x >= 4 * b * b) { return sqrt((a * a) / (x * x - b * b)) + 1; } else { int ans = a / x * 2; int res = a % x; // res < sqrt(x^2 - b^2) if(res * res < x * x - b * b) { return ans + 1; } int c = res; long double x2 = x * x, c2 = c * c, b2 = b * b; long double qwq = (sqr(c - sqrt(x2 - b2)) + sqr(b - sqrt(x2 - c2)) - x2); int flag = (x * x - 2ll * c * sqrt(x * x - b * b) - 2ll * b * sqrt(x * x - c * c)) >= 0; int flag2 = qwq >= 0; if(flag != flag2) while(1); return ans + 2 + flag; } } #undef int int main() { int test; scanf("%d", &test); while(test--) { printf("%lld\n", Solve()); } }