Know H, H and D, H: the height of the lamp, H is the height of the person, D is the distance between the lamp and the wall, requiring the maximum length of the shadow l
This kind of math problem is the most disgusting. At first I got wrong d, so the formula was wrong. Fortunately, mjy helped me.
Result: L = (h-h) * D/(d-x) + H + x
With the formula, it is very watery... three points.
/* Problem ID: Meaning: analyzing: */# include <iostream> # include <cstdio> # include <cmath> # include <cstdlib> # include <cstring> # include <vector> using namespace STD; typedef struct even {int Y1, Y2, X;} Even; # define for (I, S, T) for (INT I = (s); I <(t ); I ++) # define ll long # define bug puts ("here !!! ") # Define print (x) printf (" % d \ n ", x) # define stop system (" pause ") # define EPS 1e-8 # define PI ACOs (-1.0) # define lson L, M, RT <1 # define rson m + 1, R, RT <1 | 1 # define maxn 16666ll gcd (ll a, LL B) {return? Gcd (B % A, A): B;} double D, H, H; double F (Double X) {return (h-h) * D/(d-x) + H + X;} int main () {int t; CIN> T; while (t --) {scanf ("% lf", & H, & H, & D); double L = 0, r = H * D/h; double mid, midmid; while (R-L> EPS) {mid = (L + r) /2; midmid = (R + mid)/2; If (f (MID)> F (midmid) r = midmid; else l = mid;} printf ("%. 3lf \ n ", F (l);} return 0 ;}