시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 226 | 45 | 42 | 28.000% |
A quadratic equation
\[ax^2 + bx + c = 0\]
has two solutions \(x_{+}\) and \(x_{−}\), called roots, which are given by
\[x_{\pm} = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a}\]
The two roots may be real or complex, and they may be identical or distinct. Given a quadratic equation and an interval [\(s\), \(t\)] (with \(s\) ≤ \(t\)), we want to know if the equation has a real root in the interval [\(s\), \(t\)]. That is, is it the case that \(s\) ≤ \(r\) ≤ \(t\) where \(r\) is any of the roots \(x_{−}\) or \(x_{+}\)?
The first line of the input contains an integer, N, the number of test cases (1 ≤ N ≤ 1, 000). Then follows N lines, each containing five integers, \(a\), \(b\), \(c\), \(s\), and \(t\), with −107 ≤ \(a\), \(b\), \(c\), \(s\), \(t\) ≤ 107 , \(a\) ≠ 0, and \(s\) ≤ \(t\).
For each of the N test cases, output “Yes” if the equation \(ax^2 + bx + c = 0\) has a real root in the interval [\(s\), \(t\)]. Output “No” otherwise.
3 1 0 0 -1 0 -1 5 -4 2 3 4 4 1 0 100
Yes No No