标签:y2 Lines Rain y1 x2 line x1 lld
链接:登录—专业IT笔试面试备考平台_牛客网
来源:牛客网
空间限制: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(1\leq T\leq 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^9\leq x_1,y_1,x_2,y_2,A,B,C\leq 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^2\neq 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 02 1 1 -1 -1 1 1 0 1 1 2 2 1 1 0
输出
复制No YesNo Yes
//签到题
#include<stdio.h>
#include<math.h>
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;
}
标签:y2,Lines,Rain,y1,x2,line,x1,lld 来源: https://blog.csdn.net/bairimeng16/article/details/122275974
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。