Rain

Rain,第1张

Rain

链接:登录—专业IT笔试面试备考平台_牛客网
来源:牛客网
 

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld 题目描述 Rain_w gives you two different points P(x1,y1),Q(x2,y2)P(x_1,y_1),Q(x_2,y_2)P(x1​,y1​),Q(x2​,y2​)   and a line  l:Ax+By+C=0l:Ax+By+C=0l:Ax+By+C=0 . She wants to know if PPP and QQQ are on the same side of the line lll . Please help her. 输入描述:
 
 

The input has multiple test cases.

The first line contains a single integer  T(1≤T≤104)T(1leq Tleq 10^4)T(1≤T≤104) - the number of test case.

Next  TTT lines, each line contains 7 integers x1,y1,x2,y2,A,B,C(−109≤x1,y1,x2,y2,A,B,C≤109)x_1,y_1,x_2,y_2,A,B,C(-10^9leq x_1,y_1,x_2,y_2,A,B,Cleq 10^9)x1​,y1​,x2​,y2​,A,B,C(−109≤x1​,y1​,x2​,y2​,A,B,C≤109) separated by space. It is guaranteed that A2+B2≠0,(x1,y1)≠(x2,y2)A^2+B^2neq 0,(x_1,y_1)neq (x_2,y_2)A2+B2​=0,(x1​,y1​)​=(x2​,y2​),and P,QP,QP,Q are not on the line lll.

输出描述:
The output should contains TTT lines. Each line should be a string "Yes" if P,QP,QP,Q on the same side of the line lll, or a string "No" if P,QP,QP,Q on the different side of the line lll.
示例1 输入 复制2 1 1 -1 -1 1 1 0 1 1 2 2 1 1 0
2
1 1 -1 -1 1 1 0
1 1 2 2 1 1 0
输出 复制No Yes
No
Yes

 

//签到题
#include
#include
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		long long x1, y1, x2, y2, a, b, c;
		double p, q;
		scanf("%lld %lld %lld %lld %lld %lld %lld", &x1, &y1, &x2, &y2, &a, &b, &c);
		if (b == 0)
		{
			double o = -1 * c * 1.0 / a;
			if (x1 > o && x2 > o || x1 < o && x2 < o)
				printf("Yes");
			else
				printf("No");
		}
		else
		{
			p = -1 * (a * 1.0 / b);
			q = -1 * (c * 1.0 / b);
			double lowy1 = p * x1 + q;
			double lowy2 = p * x2 + q;
			if (lowy1 > y1 && lowy2 > y2 || lowy1 < y1 && lowy2 < y2)
				printf("Yes");
			else 
				printf("No");
		}	
		if (t > 0)
			printf("n");
	}
	return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5691622.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存