2020多校第四场F. Finding the Order[思维][几何数学][AB//CD or AB//DC????]

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,DA,B,C,D are all distinct points.  

You only know the Euclidean Distances between AC,AD,BC,BDAC,AD,BC,BD. but you don't know the exact order of points. (i.e. You don't know whether it's AB∥CDAB∥CD or AB∥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≤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≤a,b,c,d≤1000) in a line, indicating the distances between AC,AD,BC,BDAC,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∥CD, or output 'AB//DC' (Quotation marks) if AB∥DCAB∥DC.

示例1

输入

复制

2
3 5 5 3
5 3 3 5

输出

复制

AB//CD
AB//DC

看看谁的头更铁的签到题

在这里插入图片描述

我们知道三角形任意的俩边之和大于第三边
那么根据图中可知:
在AB//DC的情况下,ac + bd > ad + bc
在AB//CD的情况下,ad + bc > ac + bd

中点为O

ac+bd=(ao+oc)+(bo+od)=(ao+od)+(bo+oc)>ad+bc

果断就会白给

我一开始蒙的乘积就没有过-。-

#include <bits/stdc++.h>
inline long long read()
{
    char c = getchar();
    long long x = 0,s = 1;
    while(c < '0' || c > '9')
    {
        if(c == '-') s = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
    {
        x = x*10 + c -'0';
        c = getchar();
    }
    return x*s;
}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 1e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9+7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int ac,ad,bc,bd;
        cin >> ac >> ad >> bc >> bd;
        ac + bd > ad + bc ? cout << "AB//DC" << endl : cout << "AB//CD" << endl;
    }
}

参考https://blog.csdn.net/moasad/article/details/107474428?ops_request_misc=&request_id=&biz_id=102&utm_term=2020牛客多校第四场&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~sobaiduweb~default-1-107474428

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值