HDU 2547 无剑无我(数学)

#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) 
*/

  

posted @ 2017-07-20 00:08  Roni_i  阅读(198)  评论(0编辑  收藏  举报