#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
double f(int a, int b, int c, double x) {
return a * x * x + b * x + c;
}
double findMinimum(int n, const vector<int>& aVec, const vector<int>& bVec, const vector<int>& cVec) {
double l = 0, r = 1000, f1, f2;
while (r - l > 0.00001) {
double mid1 = l + (r - l) / 3;
double mid2 = r - (r - l) / 3;
f1 = -100, f2 = -100;
for (int i = 0; i < n; i++) {
f1 = max(f1, f(aVec[i], bVec[i], cVec[i], mid1));
f2 = max(f2, f(aVec[i], bVec[i], cVec[i], mid2));
}
if (f1 <= f2)
r = mid2;
else
l = mid1;
}
return l;
}
int main() {
int t;
cin >> t;
while (t > 0) {
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
double result = findMinimum(n, a, b, c);
printf("%.4f\n", result);
t--;
}
return 0;
}
请问为什么这里测试点都能通过,为什么一分都没有啊?
请各位帮忙看看