Zoj 3203 light bulb (three points)

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.