栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

K - Table

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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
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("YESn");
    else
        printf("NOn");
}

别人的题解:

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

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

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/879075.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号