#include<cstdio> #include<iostream> #include<cmath> int main() { double a,b,c,d,m; int t; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf",&a,&b,&c,&d); m=sqrt((a-c)*(a-c)+(b-d)*(b-d)); printf("%.1f\n",m); } } /*f(x, y, m, n) = sqrt(x*x + y*y + m*m + n*n - 2*m*x - 2*n*y) = sqrt((x-m)^2+(y-n)^2)相当于距离 而 f(x, y, a, b) + f(x, y, c, d)的最小值则为点(a,b)到点(c,d)的距离,即是求 f(a, b, c, d) */
时间: 2024-10-13 06:45:48