Play together with Wu Hao reasoning Round 8 -- computation of a series of ry (c) -- know one point on the circle and find the other two points to form a triangle with the longest circumference (hdoj 1700)

Source: Internet
Author: User

 

Source: hdoj 1700

 

Mathematical Proof]

If R is the circle radius, A, B, and C are the angles of triangles, A/Sina = B/sinb = C/sinc = 2R is obtained from the sine theorem.

Therefore, A + B + C = 2R (SINA + sinb + sinc). When r determines that the circumference A + B + C is the largest, the sum is the maximum of SINA + sinb + sinc.

Set y = SINA + sinb + sinc, first fixed angle,

Y = SINA + sinb + sinc = SINA + 2sin (B + C)/2) Cos (B-C)/2)

= SINA + 2cos (A/2) Cos (B-C)/2)

Because a is a fixed value, only when B = C, Y has the maximum value. Similarly, if C = A, A = B,

Y has the maximum value, so when a = B = c = 60, the Y value is the maximum, that is, the circumference A + B + C is the maximum.

That is, the triangle with the largest circumference in the same circle or other circles is an equilateral triangle.

 

1 [general method]
2
3
4
5 # include <stdio. h>
6 # include <math. h>
7 # define PI ACOs (-1.0)
8 # define epx 0.0005
9 int main ()
10 {
11 int T;
12 double X1, Y1, X2, Y2, X3, Y3, A, R, B;
13 scanf ("% d", & T );
14 While (t -- & scanf ("% lf", & X1, & Y1 ))
15 {
16 R = SQRT (x1 * X1 + Y1 * Y1 );
17 if (x1! = 0 & Y1! = 0)
18 {
19 if (X1 <0 & Y1 <0) A = PI + atan (Y1/X1 );
20 else if (X1 <0 & Y1> 0) A = PI + atan (Y1/X1 );
21 else a = atan (Y1/X1 );
22}
23 else if (x1 = 0 & Y1! = 0)
24 {
25 if (Y1> 0) A = PI/2;
26 else a =-PI/2;
27}
28 else if (x1! = 0 & Y1 = 0)
29 {
30 if (x1> 0) A = 0;
31 else a = PI;
32}
33 B = 2 * PI/3 +;
34x2 = cos (B) * R; y2 = sin (B) * R;
35x3 =-(X1 + x2); Y3 =-(Y1 + y2 );
36 IF (FABS (y2-y3) <epx)
37 {
38 If (X2 <X3) printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X2, Y2, X3, Y3 );
39 else printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X3, Y3, X2, Y2 );
40}
41 else
42 {
43 If (Y2 <Y3) printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X2, Y2, X3, Y3 );
44 else printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X3, Y3, X2, Y2 );
45}
46}
47}
48
49
50 [Complex Plane Method]
51
52 # include <stdio. h>
53 # include <math. h>
54 # define s SQRT (3.0)
55 # define epx 0.0005
56 int main ()
57 {
58 int T;
59 double X1, Y1, X2, Y2, X3, Y3, A, R, B;
60 scanf ("% d", & T );
61 while (t -- & scanf ("% lf", & X1, & Y1 ))
62 {
63x2 =-(X1 + S * Y1)/2;
64 y2 = (S * x1-y1)/2;
65x3 =-(X1 + x2); Y3 =-(Y1 + y2 );
66 If (FABS (y2-y3) <epx)
67 {
68 if (X2 <X3) printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X2, Y2, X3, Y3 );
69 else printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X3, Y3, X2, Y2 );
70}
71 else
72 {
73 If (Y2 <Y3) printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X2, Y2, X3, Y3 );
74 else printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X3, Y3, X2, Y2 );
75}
76}
77}
78
79 [vector method]
80
81 p (x, y) is set. One equation is POW (x, 2) + POW (Y, 2) = POW (R, 2). The other equation is based on vector knowledge, the angle formula of the vector is used to obtain the equation. Cos (2PI/3) = a * B/| A | * | B |; (A and B are vectors). If we know the angle and a vector, we can obtain B (X, Y ). the equations can be used to obtain (x, y). The quadratic equations of the first element are obtained. Two solutions can be obtained, that is, the scalar of two points.
82
83 # include <stdio. h>
84 # include <math. h>
85 struct point
86 {
87 Double X;
88 Double Y;
89 };
90 int main ()
91 {
92 Point P1, P2, P3;
93 double A, B, C, R, Delta;
94 int T, I;
95 for (; scanf ("% d", & T )! = EOF ;)
96 {
97 for (I = 0; I <t; I ++)
98 {
99 scanf ("% lf", & p1.x, & p1.y );
100 r = SQRT (p1.x * p1.x + p1.y * p1.y );
101 A = p1.x * p1.x + p1.y * p1.y;
102 B = p1.y * r * R;
103 C = (-p1.x * p1.x * r + R * r/4 );
104 Delta = B * B-4 * a * C;
105 p2.y = (-1 * B-SQRT (DELTA)/(2 * );
106 p3.y = (-1 * B + SQRT (DELTA)/(2 * );
107 If (p1.x = 0)
108 {
109 p2.x =-SQRT (R * r-p2.y * p2.y );
110 p3.x = SQRT (R * r-p2.y * p2.y );
111}
112 else
113 {
114 p2.x = (-1 * r/2-p1.y * p2.y)/p1.x;
115 p3.x = (-1 * r/2-p1.y * p3.y)/p1.x;
116}
117
118 printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", p2.x, p2.y, p3.x, p3.y );
119}
120}
121 return 0;
122}
123 [Equations method]
124
125 it is known that a Circle centered on (0, 0) and a point on the circle (x0, y0) Calculate the other two points on the circle (x1, Y1,) (X2, Y2 ), the angle between the vectors (x1, Y1) (X2, Y2) and (x0, y0) is 120 degrees.
126
127 this topic mainly uses the cross multiplication and point multiplication of vectors to list two binary systems of one-time equations.
128
129 1.
130
131 (x0, y0) x (x1, Y1) = sin (120) * R ^ 2 (r is the circle radius)
132
133 (x0, y0) * (x1, Y1) = cos (120) * R ^ 2
134
135 results:
136
137x1 = B * x0-a * y0; A = sin120
138 Y1 = B * y0 + A * x0; B = cos120;
139
140 2.
141
142 (x0, y0) x (X2, Y2) =-sin (120) * R ^ 2 (r is the circle radius)
143
144 (x0, y0) * (X2, Y2) = cos (120) * R ^ 2
145
146 Note: The question assumes that the vector (x1, Y1) returns a positive value in the clockwise direction of the vector (x0, y0 ).
147
If 148 (X2, Y2) is in the clockwise direction of (x0, y0), the result of cross multiplication is negative.
149
150 # include <stdlib. h>
151 # include <stdio. h>
152 # include <math. h>
153 int main (INT argc, char ** argv ){
154
155
156 double A, B, SiNx, cosx, x0, y0, X1, Y1, X2, Y2;
157 int T;
158
159 A = SiNx = SQRT (3.0)/2;
160 B = cosx =-0.5;
161 scanf ("% d", & T );
162 while (t --)
163 {
164 scanf ("% lf", & x0, & y0 );
165
166x1 = B * x0-a * y0;
167 Y1 = B * y0 + A * x0;
168x2 = B * x0 + A * y0;
169 y2 = B * y0-a * x0;
170 If (Y1 <Y2 | (ABS (y1-y2) <0.005) & X1 <X2 ))
171 {
172 printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X1, Y1, X2, Y2 );
173}
174 else
175 printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n", X2, Y2, X1, Y1 );
176
177}
178
179 return (exit_success );
180}

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.