牛客多校(2020第四场)F Finding the Order

题目链接:https://ac.nowcoder.com/acm/contest/5669/F

题意:

  • 有俩条平行线AB,CD
  • 给出AC,AD,BC,BD,问AB//CD还是AB//DC

题解:

  • 找到这四个距离的最大值
  • 如果最大值来自AD,BC则是AB//CD,否则为AB//DC
 1 #include<iostream>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<string>
 5 using namespace std;
 6 
 7 int a, b, c, d;
 8 
 9 void solve() {
10     int max_len = max(max(a,b), max(c,d));
11     if (max_len == b || max_len == c) {
12         printf("AB//CD\n");
13     }
14     else {
15         printf("AB//DC\n");
16     }
17 }
18 
19 int main() {
20     int t;
21     cin >> t;
22     while (t--) {
23         cin >> a >> b >> c >> d;
24         solve();
25     }
26     return 0;
27 }

猜你喜欢

转载自blog.csdn.net/Mrwei_418/article/details/108092095