Simple Algebra

2023-03-10,

题意

给定方程\(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;
}

Simple Algebra的相关教程结束。

《Simple Algebra.doc》

下载本文的Word格式文档,以方便收藏与打印。