「 1.2 Exercise 3 」 bulb (trigger/formula) (trigonometric function, computational ry)

Source: Internet
Author: User

Portal

This question should contain a little trigonometric function...

Don't be afraid. As long as you have rational thinking, you can know how to do it.

Du Niang!

Let me talk about my understanding of trigonometric functions. Simply put, if you know an acute angle of a right triangle, then you know the shape of the right triangle (obtain the number of angles of the three angles). If the three angles of the other right triangle are equal to the triangle, then the two of them can be converted in proportion, and the ratio of any two sides of the three sides is equal (that is, the ratio of any two sides if the degree of the angle is fixed, then the ratio of the two sides is fixed ).

Amway:

If the shadow of a person is not on the wall, then the person goes from the bottom of the lamp to the right, and the farther the shadow goes, the longer the Shadow grows! The longest case is as follows:

Because the ratio is the same, the length of the shadow is l, and the person is X meters away from the lamp.
\ [H: D = H: l \]
\ [So DH = HL \]
\ [DH/h = L \]

Then we can see that the maximum value of L is DH/h when the shadow is all over the ground. In this case, X is D-DH/h and left = D-DH/H is set.
Then, if the shadow is all on the wall, L = H, x = D, and set right to D.
If the shadow is on the wall, it is abstract...


Then ...?

So:

\ [So (h-h): x = KK :( D-x) \]
\ [(H-h) * (D-x) = x * KK \]
\ [(H-h) * (D-x)/x = KK \]
The shadow on the wall is
\ [H-kk = H-(h-h) * (D-x)/x = H-(h-h) * D/X \]
\ [L = D-x + (H-kk) = D-x + H-(h-h) * D/X \]
\ [= D + H-(x + (h-h) * D/x) \]

So we need to take \ (x + (h-h) * D/X \) to the minimum value. It can be proved that in the positive number range, \ (x + (h-h) * D/X \) is an open-up single-peak function.

Certificate:
Case 1: X increases y, \ (h-h) * D/X \) decreases more than Y
Case 2: X increases y, \ (h-h) * D/X \) decreases less than Y
The larger the value of X, the smaller the number of \ (h-h) * d \)/X is, the change from Case 1 to case 2 is expected, as a result, the change from decline to rise becomes a single peak.

Therefore, \ (D + H-(x + (h-h) * D/x) \) is an open-down single-peak function!(What is the purpose of your entire project ?)

I said there were images!

Implementation:
L = left, r = right;
When the answer is l, it indicates the maximum value of all shadows on the ground.
When the answer is "r", it indicates that the shadow is on the wall.Maximum value.
When the answer is (L, R), it indicates the maximum value of half of the shadow on the wall and half of the shadow on the ground.

Code:

# Include <cstdio> # include <cstring> using namespace STD; typedef long ll; inline double mymax (Double X, Double Y) {return x> Y? X: Y;} inline double CAI (double H, double H, double D, ll X) {double xx = x/10000.0; return H + D-XX-(h-h) * D)/xx;} // The previously introduced function Double sanfen (double H, double H, double D) {ll l = LL (D-(H * D)/h) * 10000.0), r = LL (D * 10000.0); // multiply by 10000 to ll M1, m2; while (L <r) // three points {M1 = (L + r)/2; M2 = (L + r)/2 + 1; if (CAI (H, h, D, M1)> CAI (H, H, D, m2) r = m1; else l = m2;} return CAI (H, H, D, L ); // there is only one real elephant, and l or R is the answer} int main () {int t; scanf ("% d", & T); While (t --) {double H, h, D; scanf ("% lf", & H, & H, & D); printf ("%. 3lf \ n ", sanfen (H, H, D); // output} return 0 ;}
Formula:

Because I have been reading this question for a long time (tears rush) (: Escape speed of light

Then, if you are a huge veteran, you will surely think of the formula...

\ [We set (h-h) * D to A, and set B, C, and D to a value of X. \]
\ [C is the single peak of X + (h-h) * D/X \]
\ [And B <C <D \]
\ [B + A/B> C + A/C <D + A/D \]
\ [Obtained from B + A/B> C + A/C \]
\ [B-C> A/C-A/B \]
\ [B-C> A (B-C)/BC \]
\ [BC (B-C)> A (B-C) \]
\ [BC <A \]
\ [Because C <B, BC <C ^ 2 \]
Is it \ (A = C ^ 2 \)Prove it, yeah!Think too much

Amway:

\ [However, C + A/C <D + A/D \]
\ [C-D <A/D-A/C \]
\ [C-D <A (C-D)/CD \]
\ [Cd (C-D) <A (C-D) \]
\ [Cd> A \]
\ [And because D> C, Cd> C ^ 2 \]
Then we can say \ (A = C ^ 2!
So \ (C = SQRT ()\)
Therefore, when \ (x \) is equal to \ (SQRT (h-h) * D) \), \ (x + (h-h) * D/X \) located on a single peak, and \ (D + H-(x + (h-h) * D/x) \) is also located on a single peak

Of course, when \ [x <= left \], due to \ (D + H-(x + (h-h) * D/x )\) is an open-down single-peak function, and \ (x = [left, right] \) SO x = left.
Similarly, when \ (x> = right \), x = right!

Code:

# Include <cstdio> # include <cstring> # include <cmath> using namespace STD; int main () {int t; scanf ("% d", & T ); while (t --) {double H, H, D; scanf ("% lf", & H, & H, & D ); double X = SQRT (h-h) * D); If (x <= D-(H * D)/h) printf ("%. 3lf \ n ", (H * D)/H); // all else if (x> = d) printf (" %. 3lf \ n ", H); // all the else printf (" %. 3lf \ n ", H + D-x * 2); // some are on the ground and some are on the wall} return 0 ;}

Escape speed of light, yeah! Finished!

「 1.2 Exercise 3 」 bulb (trigger/formula) (trigonometric function, computational ry)

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.