#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define ld long double void solve(){ ll a,b,r1; ll c,d,r2; cin >> a >> b >> r1 >> c >> d >> r2; ld A = a, B = b, C = c, D = d, R1 = r1, R2 = r2;//各数字のlong double版を作成 ll L_squared = (c-a)*(c-a)+(d-b)*(d-b);//円の中心間距離の二乗 vector theta(4); if (d - b == 0){ theta[0] = acosl((R1+R2)/(C-A)); theta[1] = -theta[0]; theta[2] = acosl((R2-R1)/(A-C)); theta[3] = -theta[2]; } if (d - b > 0){ theta[0] = asinl((R1+R2)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[1] = M_PIl - asinl((R1+R2)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[2] = M_PIl + asinl((R2-R1)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[3] = 2*M_PIl - asinl((R2-R1)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); } if (d - b < 0){ theta[0] = M_PIl + asinl((R1+R2)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[1] = 2*M_PIl - asinl((R1+R2)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[2] = asinl((R2-R1)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); theta[3] = M_PIl - asinl((R2-R1)/sqrtl(L_squared)) - atanl((C-A)/(D-B)); } ld X = 0.0; for (ll i = 0; i < 4; i++){//それぞれのθの値に対して、直線の式の係数を求め、変換を行ってXに加算する。 ld s = cosl(theta[i]); ld t = sinl(theta[i]); ld u = -R1 - B*sinl(theta[i]) - A*cosl(theta[i]); ld M = max(abs(s),max(abs(t),abs(u))); X += abs(s/M + t/M + u/M); } cout << X << "\n"; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll T; cin >> T; cout << fixed << setprecision(16); for (ll i = 0; i < T; i++){ solve(); } }