#P1883. 【模板】三分 / 函数 / [ICPC-Chengdu 2010] Error Curves

【模板】三分 / 函数 / [ICPC-Chengdu 2010] Error Curves

Description

Given nn quadratic functions f1(x),f2(x),,fn(x)f_1(x), f_2(x), \dots, f_n(x) (each of the form ax2+bx+cax^2+bx+c), let F(x)=max{f1(x),f2(x),...,fn(x)}F(x)=\max\{f_1(x),f_2(x),...,f_n(x)\}. Find the minimum value of F(x)F(x) on the interval [0,1000][0, 1000].

Input Format

The first line contains a positive integer TT, the number of test cases.

For each test case, the first line contains a positive integer nn. Then nn lines follow, each with 33 integers a,b,ca, b, c representing the three coefficients of a quadratic function. Note that a quadratic function may degenerate into a linear function.

Output Format

For each test case, output one line with the minimum value of F(x)F(x) on the interval [0,1000][0, 1000]. The answer should be rounded to 44 decimal places.

2
1
2 0 0
2
2 0 0
2 -4 2

0.0000
0.5000

Hint

For 50%50\% of the testdata, n100n \le 100.

For 100%100\% of the testdata, T<10T < 10, n104n \le 10^4, 0a1000 \le a \le 100, b5×103|b| \le 5 \times 10^3, c5×103|c| \le 5 \times 10^3.

Translated by ChatGPT 5