2020牛客暑期多校训练营(第四场)F. Finding the Order(思维)

题目传送
题意:
给你在已知AB//CD的情况下,给出AC,AD,BC,BD的长度,让你判断是是AB//CD还是AB//DC

思路:
签到题总是给我惊喜的做法,感觉思维再一次被碾压
看图
在这里插入图片描述
我们知道三角形任意的俩边之和大于第三边
那么根据图中可知:
在AB//DC的情况下,ac + bd > ad + bc
在AB//CD的情况下,ad + bc > ac + bd
所以我们直接判断ad + bc和ac + bd的大小情况即可了

AC代码

#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;
    }
}

猜你喜欢

转载自blog.csdn.net/moasad/article/details/107474428