K - Table

SDUT 2022 Spring Individual Contest(for 21) - 6 - Virtual Judge

There are 4 bars, possibly, having different lengths. Can they be used as the legs of the table, such that:

  • The legs stay vertically in the vertices of some rectangle;
  • The surface of the table, possibly, sloping, touches all four legs?

Input

The input contains 4 integers a_1a1​, a_2a2​, a_3a3​, a_4a4​ (1 \le a_i \le 10^91≤ai​≤109) — the lengths of the bars.

Output

Output "YES" or "NO", depending on it is possible to make a table with the given design or not.

Sample 1

InputcopyOutputcopy
1 1 1 1
YES

Sample 2

InputcopyOutputcopy
1 5 1 5
YES

Sample 3

InputcopyOutputcopy
1 3 2 2
YES

Sample 4

InputcopyOutputcopy
9 5 11 8
NO

题意:给定一个桌子的四个桌脚的长度,判断这四个桌脚能否恰好保证支撑起这个桌子(即保证桌面是一个平面)。 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i=0;i<4;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+4);
    if(a[1]-a[0]==a[3]-a[2])
       printf("YES\n");
    else
        printf("NO\n");
}

别人的题解:

设这四根桌脚的长度分别为 a0,a1,a2,a3。a0,a1,a2,a3 (从小到大排列),如果 ABCDABCD 为一平面,则必须满足:

|DM|=|CN|⇔a3-a1=a2-a0

 面CBAD是一个面--->CB==AD-->三角形CBN与三角形DMA全等

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值