Poj1927 area in triangle solution report

Source: Internet
Author: User

Question link: http://poj.org/problem? Id = 1927

Question:

Area in triangle
Time limit:1000 ms   Memory limit:30000 K
Total submissions:1227   Accepted:662

Description

Given a triangle field and a rope of a certain length (figure-1), you are required to use the rope to enclose a region within the field and make the region as large as possible.

Input

The input has several sets of test data. each set is one line containing four numbers separated by a space. the first three indicate the lengths of the edges of the triangle field, and the fourth is the length of the rope. each
Of the four numbers have exactly four digits after the decimal point. the line containing four zeros ends the input and shoshould not be processed. you can assume each of the edges are not longer than 100.0000 and the length of the rope is not longer than
Perimeter of the field.

Output

Output one line for each case in the following format:

Case I: x

Where I is the case number, and X is the largest area which is rounded to two digits after the decimal point.

Sample Input

12.0000 23.0000 17.0000 40.000084.0000 35.0000 91.0000 210.0000100.0000 100.0000 100.0000 181.38000 0 0 0

Sample output

Case 1: 89.35Case 2: 1470.00Case 3: 2618.00
 
 
Give you a triangle and give you three sides. Give you another rope, known length, and find the maximum area that the rope can enclose in a triangle.
Train of Thought: This question is divided into three situations
(1) The biggest circle radius enclosed by the rope is smaller than the radius of the triangle's incircle.
(2) If the rope is longer than or equal to the sum of the three sides of a triangle, the answer is the Triangle Area.
(3) The length of the rope is between the two conditions. The following special instructions:
In this way, the rope has the largest surrounding area (arc-length DC + CB + arc-length BA + AF + arc-length Fe + ed), and the three slices will constitute an integral circle o, with O1, O2, the straight lines connected by O3 are vertical triangles (it turns out to be physical, I don't understand it). You can imagine it was a balloon that was inflated in it.
Rope length-three-side small arc lengths = large triangle perimeter-(EC + CF + AA + AB + CB + BD, set to T below) = (three coarse line lengths)
R: r = T: triangle perimeter (r is the radius of the circle composed of three slices, r is the radius of the triangle incircle) this is because the triangle is similar to the Circle center of a large triangle, and the vertical lines of each side are made respectively (the figure is not drawn) we can clearly see that the Quadrilateral cfo3e and the other two constitute a triangle and are similar to a large triangle. The circle composed of three slices is the incircle of the triangle.
Large triangle perimeter

Large triangle perimeter
Then, we can find the R, so answer = the area of the small triangle formed by the area S-(S * (R * r)/(R * R) of the large triangle) + small circular area
Ah, I have read the code on the Internet for a long time and finally understood it.
AC code:
# Include <stdio. h> # include <iostream> # include <math. h ># include <iomanip> using namespace STD; const double Pi = ACOs (-1.0); int main () {int I = 1; Double A, B, C, Len; while (CIN> A> B> C> Len) {if (a = 0 & B = 0 & C = 0 & Len = 0) break; Double P, R, S, R, max = 0, half; P = A + B + C; half = p/2; S = half * (half-A) * (half-B) * (half-C); s = SQRT (s); r = s/half; If (LEN/(2 * PI) <= r) max = (LEN/(pI * 2) * (LEN/(2 * PI) * PI; else if (LEN> = P) max = s; else {r = (p-len)/(P/R-2 * PI ); max = S + pI * r-S * (R * r/(R * r);} cout <"case" <I <": "<fixed <setprecision (2) <max <Endl; // control precision I ++;} return 0 ;}
Related Article

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.