F Simple Algebra

题目描述

Given function f(x,y)=ax2+bxy+cy2f(x, y) = a x^2 + b xy + c y^2f(x,y)=ax2+bxy+cy2, check if f(x,y)≥0f(x, y) \geq 0f(x,y)≥0 holds for all x,y∈Rx, y \in \mathbb{R}x,y∈R.

输入描述:

The input contains zero or more test cases and is terminated by end-of-file.
Each test case contains three integers a, b, c.

  • −10≤a,b,c≤10-10 \leq a, b, c \leq 10−10≤a,b,c≤10
  • The number of tests cases does not exceed 10410^4104.
输出描述:

For each case, output “Yes” if f(x,y)≥0f(x, y) \geq 0f(x,y)≥0 always holds. Otherwise, output “No”.

输入

1 -2 1
1 -2 0
0 0 0

输出

Yes
No
Yes

分类讨论,分别讨论a大于小于等于0的情况,然后逐个分析,,当然,这题数据范围小,暴力打表也能过。

#include <iostream>
using namespace std;

void yes()
{
	cout << "Yes" << endl;
}

void no()
{
	cout << "No" << endl;
}

int main()
{
	int a, b, c;
	while(cin >> a>> b>> c)
	{
		if(a < 0)
			no();
		else if(a == 0)
		{
			if(b == 0)
			{
				if(c < 0)
					no();
				else
					yes();
			}
			else
				no();
		}
		else
		{
			if(b * b - 4 * a * c <= 0)
				yes();
			else
				no();
		}
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值