欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Finding the Order

程序员文章站 2022-03-02 11:45:36
...

链接: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).

Finding the Order

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;
}
相关标签: 规律