博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Beta Round #6 (Div. 2 Only) A. Triangle 水题
阅读量:7108 次
发布时间:2019-06-28

本文共 2255 字,大约阅读时间需要 7 分钟。

A. Triangle

题目连接:

Description

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.

Sample Input

4 2 1 3

Sample Output

TRIANGLE

Hint

题意

给你四条边,然后让你选三个出来

首先问你选出来的能不能构成面积为正的三角形

如果不行,问你能不能组成面积为0的三角形

否则输出impossible

题解:

数据范围太小,直接瞎暴力吧……

代码

#include
using namespace std;int a[4];int check(int x,int y,int z){ if(x==y)return 0; if(y==z)return 0; if(x==z)return 0; x=a[x],y=a[y],z=a[z]; if(x+y>z&&x+z>y&&y+z>x)return 2; if(x+y==z||y+z==x||x+z==y)return 1; return 0;}int main(){ for(int i=0;i<4;i++) cin>>a[i]; for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) if(check(i,j,k)==2) return puts("TRIANGLE"),0; for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) if(check(i,j,k)==1) return puts("SEGMENT"),0; return puts("IMPOSSIBLE"),0;}

转载地址:http://xtlhl.baihongyu.com/

你可能感兴趣的文章
springMVC demo搭建
查看>>
JAXB完毕XML与Java对象的互转
查看>>
Android 自定义ViewGroup
查看>>
特级教师总结的教育之33条(ZZ)
查看>>
AESwithJCE http://www.coderanch.com/how-to/content/AES_v1.html
查看>>
基于keepalived搭建MySQL的高可用集群
查看>>
CTeX学习心得总结
查看>>
运算放大器相关参数基本知识(一)
查看>>
Maven中解决依赖冲突的问题
查看>>
iOS Json转换模型库:YYModel
查看>>
u-boot 2011.09 开启debug 调试
查看>>
Redis主从配置详细过程
查看>>
Swift和Objective-C混编注意
查看>>
沈阳赛区总结
查看>>
自然语言1_介绍和安装
查看>>
git: windows git ssh keys生成
查看>>
转: 系统分布式情况下最终一致性方案梳理
查看>>
Webpack学习笔记一:What is webpack
查看>>
linux磁盘空间查询
查看>>
windows中使用Findwindow函数与FindWindowEx函数来实现自动控制、触发第三方软件事件的方法...
查看>>