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 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 test(s)
Input
4 2 1 3
Output
TRIANGLE
Input
7 2 2 4
Output
SEGMENT
Input
3 5 9 1
Output
IMPOSSIBLE
//1.能组成三角形2面积为0的三角形,即一条边等于另两条之和3:1,2都不满足
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int d[][3]={{0,1,2},{0,1,3},{0,2,3},{1,2,3}};
int a[4];
int fun(int *b){
if(a[b[0]]+a[b[1]]>a[b[2]]&&a[b[2]]+a[b[1]]>a[b[0]]&&a[b[0]]+a[b[2]]>a[b[1]])
if(a[b[0]]-a[b[1]]<a[b[2]]&&a[b[2]]-a[b[1]]<a[b[0]]&&a[b[0]]-a[b[2]]<a[b[1]])
return 1;
if(a[b[0]]+a[b[1]]==a[b[2]]||a[b[2]]+a[b[1]]==a[b[0]]||a[b[0]]+a[b[2]]==a[b[1]])
return 2;
return 0;
}
int main(){
int res,i;
while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])){
for(res=i=0;i<4;i++){
int k=fun(d[i]);
if(k==1){res=-1;printf("TRIANGLE\n");break;}
else if(k==2)res=k;
}
if(res==2)printf("SEGMENT\n");
else if(res==0)printf("IMPOSSIBLE\n");
}
return 0;
}

codeforces 6A. Triangle的更多相关文章

  1. CodeForces 239A. Triangle

    Link:  http://codeforces.com/contest/407/problem/A 给定直角三角形的2个直角边a,b.求在直角坐标系中,是否存在对应的直角三角形,使得三个定点都在整点 ...

  2. codeforces C. Triangle

    C. Triangle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  3. CodeForces - 18A Triangle(数学?)

    传送门 题意: 给出三个点的坐标,初始,这三个点可以构成一个三角形. 如果初始坐标可以构成直角三角形,输出"RIGNT". 如果某个点的 x或y 坐标移动一个单位后可以组成直角三角 ...

  4. [Codeforces 15E] Triangle

    Brief Introduction: 求从N出发,回到N且不包含任何黑色三角的路径数 Algorithm:假设从N点到第二层中间的节点M的路径数为k,易知总路径数为(k*k+1)*2 而从第第四层开 ...

  5. 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 ...

  6. Codeforces Beta Round #6 (Div. 2 Only) A. Triangle 水题

    A. Triangle 题目连接: http://codeforces.com/contest/6/problem/A Description Johnny has a younger sister ...

  7. Codeforces Round #396 (Div. 2) A - Mahmoud and Longest Uncommon Subsequence B - Mahmoud and a Triangle

    地址:http://codeforces.com/contest/766/problem/A A题: A. Mahmoud and Longest Uncommon Subsequence time ...

  8. 【codeforces 766B】Mahmoud and a Triangle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. codeforces A. Vasily the Bear and Triangle 解题报告

    题目链接:http://codeforces.com/problemset/problem/336/A 好简单的一条数学题,是8月9日的.比赛中没有做出来,今天看,从pupil变成Newbie了,那个 ...

随机推荐

  1. PHP激活用户注册验证邮箱

    本文将结合实例介绍如何使用PHP+Mysql完成注册帐号.发送激活邮件.验证激活帐号.处理URL链接过期的功能. 注册邮箱激活流程 <ul class='ul_demo''> <li ...

  2. windows批处理研究_不断更新

    windows批处理脚本(bat),很麻烦,主要原因有: 1.bat脚本编写的风格,太古老,调用方式太奇怪. 2.windows自身运行机制就对批处理脚本有兼容性问题.比如,鼠标双击打开一个bat,与 ...

  3. 异步提交form的时候利用jQuery validate实现表单验证

    异步提交form的时候利用jQuery validate实现表单验证相信很多人都用过jquery validate插件,非常好用,并且可以通过下面的语句来自定义验证规则    // 电话号码验证    ...

  4. Android多媒体-MediaRecorder 录制音视频

    不多说,直接上代码,有具体凝视 MyAudioRecord.java import java.io.File; import java.io.IOException; import android.a ...

  5. 如果你使用上述这段12行的JavaScript代码,就可以能让firefox、chrome、safari浏览器崩溃,而且还能让iphone重启,安卓手机闪退!

    <html> <body> <script> var total=""; for (var i=0;i<1000000;i ) { tot ...

  6. rpt水晶报表制作过程

    原文:rpt水晶报表制作过程 最近公司安排一个以前的项目,里面需要用到水晶报表,由于原来做这个项目的同事离职,所在公司的同事报表做成了rdlc类型的,而这类报表在加载的时候很难动态的从数据库加载数据, ...

  7. Repository在DDD中的应用

    Repository在DDD中的应用2014-10-09 08:55 by Jesse Liu, 98 阅读, 0 评论, 收藏, 编辑 概述 上一篇我们算是粗略的介绍了一下DDD,我们提到了实体.值 ...

  8. 【转】在PC上测试移动端网站和模拟手机浏览器的5大方法

    查了很多资料,尝试了大部分方法,下面将这一天的努力总结下分享给大家,也让大家免去看那么多文章,以下介绍的方法,都是本人亲自测试成功的方法,测试环境winxp. 一.Chrome*浏览器 chrome模 ...

  9. ASP.NET页面生命周期和asp.net应用程序生命周期

    作为一个asp.net程序员,不了解ASP.NET页面生命周期和asp.net应用程序生命周期是绝对不行的,那永远只能是菜鸟级别.我很早就学过,可是没次还是得去翻,一些事件还是记不住,还是记在自己的b ...

  10. SpecFlow

    SpecFlow http://blog.csdn.net/yujunwu2525/article/details/7839859 将业务需求与.NET代码结合起来 SpecFlow旨在弥合领域专家与 ...