Finding the Order
链接:https://ac.nowcoder.com/acm/contest/5669/F
来源:牛客网
题目描述
ZYB has a so-called smart brain: He can always point out the keypoint in a complex problem.
There are two parallel lines AB and CD in a plane. A,B,C,D{A,B,C,D}A,B,C,D are all distinct points. You only know the Euclidean Distances between AC,AD,BC,BD{AC,AD,BC,BD}AC,AD,BC,BD. but you don’t know the exact order of points. (i.e. You don’t know whether it’s AB∥CDAB \parallel CDAB∥CD or AB∥DCAB \parallel DCAB∥DC).
Could you determine the order of points quickly, like the ZYB does?
输入描述:
The input contains multiple cases. The first line of the input contains a single integer T (1≤T≤100)T\ (1 \le T \le 100)T (1≤T≤100), the number of cases. For each case, there are four integers a,b,c,d(1≤a,b,c,d≤1000)a,b,c,d(1 \le a,b,c,d \le 1000)a,b,c,d(1≤a,b,c,d≤1000) in a line, indicating the distances between AC,AD,BC,BD{AC,AD,BC,BD}AC,AD,BC,BD.It is guaranteed that each case corresponds to a valid solution.
输出描述:
For each case, output 'AB//CD' (Quotation marks) if AB∥CDAB \parallel CDAB∥CD, or output 'AB//DC' (Quotation marks) if AB∥DCAB \parallel DCAB∥DC.
示例1
输入
复制 2 3 5 5 3 5 3 3 5
2 3 5 5 3 5 3 3 5
输出
复制 AB//CD AB//DC
AB//CD AB//DC
假设C在D前面,现在把D慢慢移动到C左边,这样发现对角线和边界线交叉了,往对角线和边界线上去想
标出对角线的点,两个对角线相加是对角点左右两个三角形的两边长度和,满足三角形两边之和大于第三边,这就是C在D前面的特征
这个题的启发是固定当前规格,动态地移动点去找规律。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define Inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+5;
int a,b,c,d;
int main(){
int T;
cin>>T;
while(T--)
{
cin>>a>>b>>c>>d;
if(b+c>a+d){
cout<<"AB//CD\n";
}else{
cout<<"AB//DC\n";
}
}
return 0;
}
上一篇: 解决前后台URL传递中文参数乱码问题
推荐阅读
-
弹性盒子中的order
-
Apache 的 order deny allow 设置说明
-
Apache中的Order Allow,Deny用法详解
-
oracle使用order by排序null值如何处理
-
Mysql优化order by语句的方法详解
-
mysql 使用order by
-
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题 MySQL
-
[MySQL] 测试where group by order by的索引问题
-
php.ini中的request_order推荐设置
-
MySQL中ORDER BY与LIMIT一起使用(有坑)