Simple Algebra
题意
给定方程\(f(x)=ax^2+bxy+cy^2\)和参数\(a\),\(b\),\(c\),试确定该方程的取值是否恒非负。
题解
参照文章http://math.mit.edu/~mckernan/Teaching/12-13/Autumn/18.02/l_10.pdf
AC代码
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0)
using namespace std;
const int N = 5e2 + 5;
bool check(int a, int b, int c) {
if (a < 0) return false;
if (!a) {
return (!b) && (c >= 0);
}
return b * b <= 4 * a * c;
}
int main() {
IO;
int a, b, c;
while (cin >> a >> b >> c) {
if (check(a, b, c)) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}