Shortest Path! Gym
阿新 • • 發佈:2018-12-20
- 題意 :從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; }