Describe
18 The 4th dream of the lay man was to become a torch-bearer. It happens that the Olympic Committee also has the last torch hand quota, so each road master crowded for this quota, clever 18 lay will hurdles hurdles, and another master to the final. The referee took them to a mysterious password door, as long as who opened the door, the door of the Xiangyun torch belongs to whom. I saw a hint on the door: "Password: F (x) =sqrt ((x+a) ^2+b) The minimum value of +sqrt ((x+c) ^2+d). "Two people looked at each other, how to do this?" So 18 of the lay man found the programming you, ask you to help him solve the problem.
Input: A,b,c,d Four Constants (B,d is full squared, 0<a, B, C, d<=10000)
Output: The minimum value of f (x) (3 decimal places reserved).
Example 1 Sample Input 1
1 1 3 4 Note: F (x) =sqrt ((x+1) ^2+1) +sqrt ((x+3) ^2+4)
Sample Output 1
3.606 Note: But X=-5/3, f (x) =sqrt (13)
Can be found that the password is actually two point distance formula expressed, can be obtained (x,0) to (-A,-SQRT (b)) and (-c,sqrt (d)) and the distance and
Because A, B, C, d are greater than 0 can be drawn this distance and is actually the distance between the two points (because the two points of the straight line intersection of the y-axis and (m,0), m must be between the two points)
Use the two-point distance formula directly.
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 inta,b,c,d;6scanf"%d%d%d%d",&a,&b,&c,&d);7 Doublek1=-a,k2=-sqrt (b);8 Doublek3=-c,k4=sqrt (d);9 DoubleAns=sqrt ((K1-K3) * (K1-K3) + (K2-K4) * (k2-K4));Tenprintf"%.3f", ans); One return 0; A}
Vijos p1433--Torch Hand Dream