C - Shortest Path! Gym - 101972C -几何-对称点距离

  • C - Shortest Path!

  •  Gym - 101972C 
  • 题意 :从room到grandmother room,有两次去河边接水第一次是从家出发时,
  • 第二次时,回来时在room与grandmother-room的
  • 直线距离的x%处去接水,所以就是求两次关于河边对称点的距离即可再加上走的那x%的距离
  • #include<bits/stdc++.h>
    using namespace std;
    int t;
    double a,b,c,x,ans,temp;
    int main()
    {
        scanf("%d",&t);
        while(t--)
        {
            ans=0;
            scanf("%lf%lf%lf%lf",&a,&b,&c,&x);
            temp=sqrt((2*c+b)*(2*c+b)+a*a);
            ans+=temp;
            temp=sqrt(a*a+b*b)*(x/100);
            ans+=temp;
            temp=sqrt((b*(1-x/100)+c*2)*(b*(1-x/100)+c*2)+(a*(1-x/100))*(a*(1-x/100)));
            ans+=temp;
            printf("%.10lf\n",ans);
        }
        return 0;
    }

猜你喜欢

转载自blog.csdn.net/BePosit/article/details/83956615