1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include <bits/stdc++.h> using namespace std;
long double distance(long double x1, long double y1, long double x2, long double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
int main() { int t; cin >> t;
while (t--) { long double px, py, ax, ay, bx, by; cin >> px >> py >> ax >> ay >> bx >> by;
long double PA = distance(px, py, ax, ay); long double PB = distance(px, py, bx, by); long double OA = distance(0.0, 0.0, ax, ay); long double OB = distance(0.0, 0.0, bx, by);
if (PA < PB && OA < OB) cout << fixed << setprecision(10) << max(OA, PA) << endl; else if (PA > PB && OA > OB) cout << fixed << setprecision(10) << max(OB, PB) << endl; else if (PA < PB && OA > OB) cout << fixed << setprecision(10) << min(min(max(OA, PA), max(OB, PB)), max(max(PA, OB), distance(ax, ay, bx, by) / 2.0)) << endl; else cout << fixed << setprecision(10) << min(min(max(OA, PA), max(OB, PB)), max(max(PB, OA), distance(ax, ay, bx, by) / 2.0)) << endl; }
return 0; }
|