P28056 [洛谷] "QFOI R2" Temple Autumn Mountains Misty Blue
普及
题目描述

Background

Formulas that may be used in this problem:

Distance formula between two points: The distance between points \((x_1, y_1)\) and \((x_2, y_2)\) is \(\sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}\).

Heron's formula: If the sides of a triangle are \(a, b, c\), and the semi-perimeter \(p = \frac{a + b + c}{2}\), then the area of the triangle is \(S = \sqrt{p(p - a)(p - b)(p - c)}\).

Problem Description

Xiao R is a lovely girl, but her geometry is poor, so she asks you for help with this geometry problem.

In the plane coordinate system, there is a \(\triangle \text{ABC}\) with vertices at \(\text{A}(x_1, y_1)\), \(\text{B}(x_2, y_2)\), and \(\text{C}(x_3, y_3)\).

For a real number \(p \in (0, 1)\), points \(\text{D}\), \(\text{E}\), and \(\text{F}\) are taken on the sides \(\text{BC}\), \(\text{CA}\), and \(\text{AB}\) respectively, such that \(\frac{|\text{AF}|}{|\text{AB}|} = \frac{|\text{BD}|}{|\text{BC}|} = \frac{|\text{CE}|}{|\text{CA}|} = p\). The triangle \(\triangle \text{DEF}\) is then called the "p-proportion triangle" of \(\triangle \text{ABC}\).

You need to choose a real number \(p\) within the range \([l, r]\) such that the area of the "p-proportion triangle" of \(\triangle \text{ABC}\) is minimized. You are required to find this minimum area.

Input Format

One line with eight real numbers \(l, r, x_1, y_1, x_2, y_2, x_3, y_3\).

Output Format

One line with a real number \(S_{\min}\), representing the minimum area.

Your output is considered correct if and only if its absolute or relative error from the standard answer does not exceed \(10^{-4}\).

Sample Input and Output

Input Example #1

0.40 0.60 0.00 0.00 4.00 0.00 1.00 5.00

Output Example #1

2.500000000000

Input Example #2

0.20 0.40 0.00 0.00 4.00 0.00 1.00 5.00

Output Example #2

2.800000000000

Notes

Sample 1 Explanation

It can be proven that when \(p = 0.5\), the area is minimized at 2.5.

Sample 2 Explanation

It can be proven that when \(p = 0.4\), the area is minimized at 2.8.

Scoring Method

This problem uses a custom checker (Special Judge) for evaluation.

Your output is considered correct if and only if its absolute or relative error from the standard answer does not exceed \(10^{-4}\).

Data Range

This problem uses bundled testing. You must pass all test cases in a subtask and all dependent subtasks to earn the corresponding score.

For all data: \(0 < l < r < 1\), \(0 \le x_1, y_1, x_2, y_2, x_3, y_3 \le 10^5\), the input guarantees a triangle, and all real numbers have at most 2 decimal places.

  • Subtask 1 (20 points): \(l = 0.10, r = 0.90\).
  • Subtask 2 (20 points): \(x_1 = y_1 = y_2 = x_3 = 0.00\).
  • Subtask 3 (20 points): \(x_1 = y_1 = y_2 = 0.00\). Dependent on Subtask 2.
  • Subtask 4 (40 points): No special restrictions. Dependent on Subtasks 1, 2, and 3.

Hints

Formulas that may be used in this problem:

Distance formula between two points: The distance between points \((x_1, y_1)\) and \((x_2, y_2)\) is \(\sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}\).

Heron's formula: If the sides of a triangle are \(a, b, c\), and the semi-perimeter \(p = \frac{a + b + c}{2}\), then the area of the triangle is \(S = \sqrt{p(p - a)(p - b)(p - c)}\).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
0.40 0.60 0.00 0.00 4.00 0.00 1.00 5.00
样例输出
2.500000000000