这题在考场上打出性质 C,为什么输入:
1 1
-1 0 0
该程序会输出 -0?
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t, m, a, b, c;
int main(){
cin >> t >> m;
while(t --){
cin >> a >> b >> c;
int delta = b * b - 4 * a * c;
if(delta < 0){
cout << "NO\n";
continue;
}
cout << max((-b + sqrt(delta)) / (2 * a), (-b - sqrt(delta)) / (2 * a)) << endl;
}
return 0;
}