P10245 题解

· · 题解

前言

你说得对,但是百度 YYDS!

思路

首先假设 a 为上底,c 为下底,b,d 为腰,则把四条边分别为 a,b,c,d 的梯形将上底和下底减去上底,这样就会变成一个边长为 b,(a-c),d 的三角形,这是只要判断 b,(a-c),d 是否能构成三角形就行了。

代码

# include <bits/stdc++.h>
using namespace std;
int t, a, b, c, d;
bool f (int a, int b, int c) {
    return a + b > c && a + c > b && b + c > a;
}
bool check (int& a, int& b, int& c, int& d) {
    return f (abs (a - c), b, d);
}
int main () {
    ios::sync_with_stdio (0);
    cin.tie (0);
    cout.tie (0);
    cin >> t;
    while (t --) {
        cin >> a >> b >> c >> d;
        cout << (check (a, b, c, d) || check (b, c, d, a) ? "yes\n" : "no\n");
    }
    return 0;
}