P10410 "QFOI R2" Temple Qiu Mountain, Misty and Gray

Background

Formulas that may be used in this problem: Distance between two points: the distance between $(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 side lengths of a triangle are $a,b,c$, let the semiperimeter be $p=\frac{a+b+c}{2}$, then the area of the triangle is $S=\sqrt{p(p-a)(p-b)(p-c)}$.

Description

Little R is a cute girl, but she is very bad at geometry, so she asks you to help with this geometry problem. In the Cartesian plane, there is a $\triangle\textrm{ABC}$ with vertices $\textrm{A}(x_1,y_1),\textrm{B}(x_2,y_2),\textrm{C}(x_3,y_3)$. For a **real number** $p\in(0,1)$, choose points $\textrm{D},\textrm{E},\textrm{F}$ on sides $\textrm{BC},\textrm{CA},\textrm{AB}$ respectively, such that $\frac{|\textrm{AF}|}{|\textrm{AB}|}=\frac{|\textrm{BD}|}{|\textrm{BC}|}=\frac{|\textrm{CE}|}{|\textrm{CA}|}=p$. Then $\triangle\textrm{DEF}$ is called the "$p$-ratio triangle" of $\triangle\textrm{ABC}$. Please choose a real number $p$ in the range $[l,r]$ to minimize the area of the "$p$-ratio triangle" of $\triangle\textrm{ABC}$. You need to output 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 one **real number** $S_{\min}$, representing the minimum area. Your output is considered correct if and only if its absolute or relative error compared to the standard answer does not exceed $10^{-4}$.

Explanation/Hint

**Explanation for Sample $1$** It can be proven that the area is minimized when $p=0.5$, and the minimum area is $2.5$. ![](https://cdn.luogu.com.cn/upload/image_hosting/stzw0bwl.png) --- **Explanation for Sample $2$** It can be proven that the area is minimized when $p=0.4$, and the minimum area is $2.8$. ![](https://cdn.luogu.com.cn/upload/image_hosting/hf4xj9tc.png) --- **Scoring** This problem is judged using a Special Judge. Your output is considered correct if and only if its absolute or relative error compared to the standard answer does not exceed $10^{-4}$. --- **Constraints** **This problem uses bundled testdata. Only by passing all test points in a subtask and all dependent subtasks can you get the corresponding score.** For all testdata: $0 < l < r < 1$, $0\le x_1,y_1,x_2,y_2,x_3,y_3\le 10^5$. The input is guaranteed to form a triangle. For every real number in the input, the number of digits after the decimal point does not exceed $2$. - 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$. Depends on Subtask 2. - Subtask 4 ($40$ points): no special constraints. Depends on Subtasks 1, 2, and 3. --- **Hint** Formulas that may be used in this problem: Distance between two points: the distance between $(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 side lengths of a triangle are $a,b,c$, let the semiperimeter be $p=\frac{a+b+c}{2}$, then the area of the triangle is $S=\sqrt{p(p-a)(p-b)(p-c)}$. Translated by ChatGPT 5