Problem description at the end of the Northern Song Dynasty, the traitor was in charge, the eunuchs were in power, the attackers were daily, and the Liao army committed another crime. Today, the war has been connected, and there have been a great number of talented people in different groups.
In the autumn of crisis, in an isolated place-a Jianghu on the mountain of the MCA said that the man who said <where did the hero come out> is studying jianfa for the fight against liaomiao thieves, at last, on the night of the thunder and lightning traffic, we accurately calculated the sword damage formula of the swing sword.
Define f (x, y, m, n) = SQRT (x * x + y * Y + M * m + n * n-2 * m * X-2 * n * y );
Hint: SQRT indicates the initiator, that is, SQRT (4) = 2; SQRT (16) = 4;
(X and Y are location variables, and m and n are attribute constants)
Sword damage = f (x, y, a, B) + f (x, y, C, D );
The Swordsman is extremely powerful and difficult to control. Now he wants to know the minimum damage value of the swordsman.
Input input a T, indicating that there is a T group of data, followed by the T line:
Input four real numbers, A, B, C, and D, all smaller than or equal to 100
Output: the minimum damage value of the swordsman (M). retain the last decimal point.
(. 1lf can be used)
Sample Input
20 0 3 44 0 0 3
Sample output
5.05.0
// I did this question in a very stupid way. After reading discuss, I realized that it was regular. But no matter how people do it, I 'd better paste my own code.
# Include <stdio. h> # include <math. h> double F (int x, int y, int M, int N) {return SQRT (x * x + y * Y + M * m + n * n-2 * m * X-2 * n * Y);} int main () {double A, B, C, D, t, x, y; double min, M; scanf ("% lf", & T); While (t --) {scanf ("% lf", & A, & B, & C, & D); min = 100000; For (x = 0; x <= 100; X ++) // use the X and Y loops to find the smallest sword. {for (y = 0; y <= 100; y ++) {M = f (x, y, a, B) + f (x, y, c, d); If (min> m) min = m ;}} printf ("%. 1lf \ n ", min);} return 0 ;}