OIer题解:P10410 「QFOI R2」寺秋山霭苍苍
greatest_show · · 题解
分析
本题的核心是将几何问题转化为二次函数极值问题:通过推导面积与
那么我们就可以定义一个函数
Code:
#include <bits/stdc++.h>
using namespace std;
double S (double p, double S0) {
return S0 * (3 * p * p - 3 * p + 1);
}
int main () {
double l, r, x1, y1, x2, y2, x3, y3;
cin >> l >> r >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
double cross = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
double S0 = fabs (cross) / 2.0;
double ma;
if (l < 0.5 && 0.5 < r) {
double s_l = S (l, S0);
double s_mid = S (0.5, S0);
double s_r = S (r, S0);
ma = min ({s_l, s_mid, s_r});
} else {
double s_l = S(l, S0);
double s_r = S(r, S0);
ma = min (s_l, s_r);
}
cout << fixed << setprecision (12) << ma << endl;
return 0;
}
AC!
OIer的题解不易,多多谅解
::::info[备注] 本文章(不包含代码)使用 Deepseek R1 进行了润色 ::::