Triangle CodeForces - 6A (三角形)

ShopNum1多用户商城系统功能说明 多用户商城系统是一套互联网目前最流行分销系统,可以方便各分司和连锁店之间无缝连接。 立即下载

Triangle

CodeForces - 6A

Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.

The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.


Input

The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.

Output

Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.

Examples
Input
4 2 1 3
Output
TRIANGLE
Input
7 2 2 4
Output
SEGMENT
Input
3 5 9 1
Output
IMPOSSIBLE
一开始怎么也看不懂这个题啥意思,因为 degenerate不知道啥意思,后来查了查才知道是退化的意思,所以给定四个长度如果

其中三个长度可以构成一个正常的三角形,两边之和大于第三边那么就输出

TRIANGLE
如果会有三个线段两边之和等于第三边,说明它退化成了一条直线,输出
SEGMENT

否则输出IMPOSSIBLE

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
    int a[5];
    for(int i = 0; i < 4; i++){
        cin >> a[i];
    }
    sort(a,a+4);
    if(a[0]+a[1]>a[2]||a[0]+a[2]>a[3]||a[1]+a[2]>a[3]||a[0]+a[1]>a[3]){
        cout << "TRIANGLE\n";
        return 0;
    }
    if(a[0]+a[1]==a[2]||a[0]+a[2]==a[3]||a[1]+a[2]==a[3]||a[0]+a[1]==a[3]){
        cout << "SEGMENT\n";
        return 0;
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}

H3C交换机S-MLAG实战:如何用bond4模式实现服务器高可用(附避坑指南) 本文详细介绍了H3C交换机S-MLAG技术与服务器bond4模式的实战配置,帮助实现跨设备链路聚合的服务器高可用方案。通过解析S-MLAG技术优势、bond4模式选择、关键配置步骤及常见问题排查,提供了一套完整的避坑指南和优化建议,适用于企业级网络架构的高可用需求。 阅读详情

相关推荐

基于单片机负载控制的无人机电气设备监测系统设计

为深入分析无人机电气设备的电子负载性能,实现对传输电子量的合理性监管与控制,设计基于单片机负载控制的无人机电气设备监测系统;利用电气信号发生电路,构建负载网络控制器与以太网模块运行所需的电气设备负载环境,借助PCB监控板建立PLC扩展负载模块与核心监控主机之间的物理连接关系,实现无人机电气设备监测系统的硬件执行环境搭建;在此基础上,通过STM32型单片机移植协议,确定无人机电气设备通信主机的现有组态形式,联合已设定的监控任务有线级条件,实现监测系统的软件执行环境搭建,完成基于单片机负载控制的无人机电气设备监

weixin_45905610的博客 1300

2022“杭电杯”中国大学生算法设计超级联赛(7)1004 Triangle Game

2022“杭电杯”中国大学生算法设计超级联赛(7)1004 Triangle Game解题报告

qq_45554473的博客 395

python知网爬虫论文pdf下载+立即可用(动态爬虫)

python实现动态爬虫知网论文,搜索+自动翻页+下载 收集数据利器

Braylon的博客 5379

Codeforces-6A Triangle

Codeforces-6A Triangle 题目链接: 题目大意:给你四个数 让你判断最好的情况能构成非退化三角形(普通三角形)还是退化三角形(三个顶点在一条直线上)还是无法构成三角形 解题思路:蛮解就好了 代码块: #include<iostream> #include<algorithm> using namespace std; typedef long lo...

鱼头的水题之路 407

python数据处理(一)——如何用python实现excel功能

python如何实现excel的数据提取、指标构建,进行透视分析。

一名数据分析师 2704

国产FPGA逆袭!深度评测复旦微RFVU3P5G核心板在相控阵雷达中的表现

本文深度评测了复旦微RFVU3P5G核心板在相控阵雷达中的实战表现。该核心板凭借射频直采架构、高采样率ADC/DAC及丰富的DSP资源,在多通道同步精度、动态范围及系统稳定性等关键指标上表现出色,展现了国产FPGA在高端雷达应用中的硬核实力与供应链自主价值。

b0c1d2的博客 724

CF 6A Triangle (判断三角形)

A. Triangle time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Johnny has a younger sister Anne, who is very clever and s

林海雪猿的代码空间 1455

Allegro模块复用:从原理图到PCB的完整流程与关键细节

本文详细介绍了Allegro模块复用从原理图到PCB的完整流程与关键细节,包括DSN和MDD文件的创建、模块调用的实战技巧以及双向同步与版本控制方法。通过标准化处理和高级复用技巧,能显著提升PCB设计效率,减少重复工作时间。适用于智能硬件和工业控制等领域的工程师。

weixin_30252709的博客 332

2022“杭电杯”中国大学生算法设计超级联赛(7)签到题5题

同时对于一对有至少两个公共点的三元环,确定了答案包含其中一个的某个点之后另一个也随之确定了。(因为独立集不能有相邻点,因此肯定是对边的那两个点同属于一个集合)求的答案是让独立集权值和尽可能大的同时,满足剩下点的诱导子图是个森林。2022“杭电杯”中国大学生算法设计超级联赛(7)2022“杭电杯”中国大学生算法设计超级联赛(7)2022“杭电杯”中国大学生算法设计超级联赛(7)2022“杭电杯”中国大学生算法设计超级联赛(7)因此答案的独立集只可能有三种,分别对应图中唯一的。...

小哈里的博客 1484

第一章:Profibus DP通信简介

PROFIBUS (Process Fieldbus)的缩写,是一种国际化的、开放的、不依赖于设备生产商的现场总线标准。它广泛应用于制造业自动化、流程工业自动化和楼宇、交通、电力等其他工业自动化领域。串行现场总线主要用来连接数字现场设备或中、低功能的系统,如传感器、执行机构、变送器、可编程序控制器(PLC)、数控装置(NC)、编程设备、本地人机接口等。

qq_22560021的博客 4894

【ESP32设备通信】-LoRa通信

在本文中,我们将使用 Arduino IDE 将 ESP32 与 LoRa SX1278 (Ra-02) 模块连接起来。 我们将创建一个真实的示例项目,通过 LoRa 无线打开/关闭 LED 进行演示。

视觉与物联智能 1890

codeforces 766B Mahmoud and a Triangle

B. Mahmoud and a Triangle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mahmoud has n line segments, the 

无知的博客 622

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

[codeforces 1398A] Bad Triangle 三角形两边之和大于第三边

Educational Codeforces Round 93 (Rated for Div. 2) 参与排名人数14614 [codeforces 1398A] Bad Triangle 三角形两边之和大于第三边 总目录详见https://blog.youkuaiyun.com/mrcrack/article/details/103564004 在线测评地址https://codeforces.com/contest/1398/problem/A Problem Lang Verdic...

mrcrack的博客 1018

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces Beta Round 6 A. Triangle

主要2个知识点,如何判定一个三角形(任意2点之和等于第三个点),还有退化三角形(存在一个2个点之和=第三个点),然后就是组合取数问题,不要求数字的排列数序,所以,每次循环+1,就是在里面再获得不同的数字。以上代码表示,从4个数字里,拿出3个数字,进行换算,三个数字没有顺序之分,所以这三个数字,组合,即可,没有前后之说。遇到同类问题都可以如此算法!明白题意,后面就解题容易,本题是DIV2 水平,一共四个水平,DIV4是最容易的,但是这个题还是比较简单。在里面第二个FOR,得到第二个顶点,就是+1位置的,

996

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

CodeForces - 939A Love Triangle (暴力水题)

Love Triangle As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There arenplanes on Earth, numbered from1ton, and the plane wi...

YOONGI 506

cf Round #635 (Div. 2)A题

A. Ichihime and Triangle 题目链接:https://codeforces.com/contest/1337/problem/A time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Ichihime is the cur...

Steve_Liu12399的博客 348

Codeforces Round #396 (Div. 2) B. Mahmoud and a Triangle 贪心

B. Mahmoud and a Triangle 题目连接: http://codeforces.com/contest/766/problem/B Description Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments ...

weixin_30612769的博客 70

Codeforces Round #635 (Div. 2) A. Ichihime and Triangle

A. Ichihime and Triangle 题目大意: 给出4个数a,b,c,d 找出 a<= x <=b b<= y <=c c<= z <=d 使得x,y,z能够构成一个三角形 思路: 因为要满足两条边之和大于第三边 所以我们可以直接用b,c,c来作为三条边,可能保证构成一个等腰三角形 AC代码: #include<cstdio> #include<iostream> #include<cstring> #include&l

遗落之辉的博客 159

CF18A 几何

http://codeforces.com/problemset/problem/18/A A. Triangle time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard o

ACM,再见! 1146

Codeforces Round #396(Div. 2)B. Mahmoud and a Triangle【上古时代题】nlogn判断三角形

B. Mahmoud and a Triangle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mahmoud has n line segments, the i-th of

mengxiang000000 763

Codeforces Round #195 (Div. 2) / 336A Vasily the Bear and Triangle(模拟&数学)

A. Vasily the Bear and Triangle http://codeforces.com/problemset/problem/336/A time limit per test 1 second memory limit per test 256 megabytes input standard input output s

AC,∑ndless 1225

Educational Codeforces Round 140 (Rated for Div. 2)题解

看看时间还有十几分钟,开不出来题了,写个题解。

Kicamon的博客 911

CodeForces - 766B Mahmoud and a Triangle

Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure

Tsaryu的博客 808

CodeForces 407A Triangle

题目地址:http://codeforces.com/problemset/problem/407/A 题意: 给你一个直角三角形的两条直角边长度a,b,判断该三角形是否满足以下约束:1,坐标都是整数,2,没有一条边和坐标轴平行。若有,输出“YES”和坐标,若无,输出“NO” 思路:假定一个点(x1,y1)在坐标原点,通过搜索由长度a确定的坐标区域,可以得到(x3,y3)的可能解。通过,直角边

独行闹市无人问,青灯剑影响素琴 1013

CodeForces - 1053A Vasya and Triangle(思维)

原题链接 题意:给定n,m,k,问能否找到x坐标在n范围内,y坐标在m范围内的三个点,使得三角形的面积=n*m/k,不存在输出NO,存在输出YES并输出三个点的坐标(任意一个解) 思路:其实就是一个公式变形题,但有的地方没有想到,,,假定存在一个直角三角形的面积满足条件,两直角边长分别为a,b,那么有 n * m / k = a * b / 2 那么有 2 * n * m / k = a ...

smilng的博客 227

codeforces 6A Triangle

A. Triangle time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Johnny has a younger sister Anne, who is very cl

ahoLic的专栏 1781
上一篇: A Spy in the Metro UVA - 1025(dp)
下一篇: Rational Resistance CodeForces - 344C(思维)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值