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

Input
4 2 1 3
Output
TRIANGLE
Input
7 2 2 4
Output
SEGMENT
Input
3 5 9 1
Output
IMPOSSIBLE

题意:

给出四个整数如果存在三个数能构成一个三角形,则输出TRIANGLE,如果任何三个数都不能构成三角形,但是存在三个数可构成退化三角形,则输出SEGMENT,如果任何三个数既不能构成三角形也不能构成退化三角形,则输出IMPOSSIBLE

退化三角形:三条边,不可以组成三角形,但是存在两条边的和等于第三条边;

AC代码:

 #include<iostream>
#include<cstdio> using namespace std;
int dp[]={};
int s[]={}; int gon()
{
if(s[]+s[]>s[]&&s[]+s[]>s[]&&s[]+s[]>s[])return ;
return ;
}
int sa()
{
int i,j;
int s;
for(i=;i<;i++)
for(j=i+;j<;j++){
for(s=;s<;s++){
if(s==i||s==j)continue;
if(dp[i]+dp[j]==dp[s]){cout<<"SEGMENT"<<endl;return ;}
}
}
return ;
}
int sk()
{
int i,j;
int a=;;
for(i=;i<;i++){
a=;
for(j=;j<;j++){
if(j!=i){
s[a++]=dp[j];
if(a==){
if(gon()==){cout<<"TRIANGLE"<<endl;return ;}
break;
}
}
}
}
if(sa()==)return ;
cout<<"IMPOSSIBLE"<<endl;
return ;
} int main()
{
int i;
for(i=;i<;i++){cin>>dp[i];}
sk();
return ;
}

E - Triangle的更多相关文章

  1. [LeetCode] Triangle 三角形

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  2. [LeetCode] Pascal's Triangle II 杨辉三角之二

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  3. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  4. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  5. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  6. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  7. Triangle - Delaunay Triangulator

    Triangle - Delaunay Triangulator  eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...

  8. LeetCode 118 Pascal's Triangle

    Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows  ...

  9. LeetCode 119 Pascal's Triangle II

    Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...

  10. 【leetcode】Triangle (#120)

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

随机推荐

  1. AsyncHttpClient 中的重定向和 setEnableRedirects 方法异常解决

    今天使用 AsyncHttpClient  开源库,遇到个很崩溃的问题: 方法  setEnableRedirects(false); 从名称上看应该是重定向开关的方法,设置为 false 后则普通请 ...

  2. RTMP直播应用与延时分析

    直播应用中,RTMP和HLS基本上可以覆盖所有客户端观看,HLS主要是延时比较大,RTMP主要优势在于延时低. 一.应用场景 低延时应用场景包括:  .  互动式直播:譬如2013年大行其道的美女主播 ...

  3. lunix存取windows共享文件夹

    在访问Windows共享资料之前,请确保Windows共享是可用的,这里就不再赘述该怎样设置Windows共享了,那可是另外一个课题. Linux访问Windows共享或者Linux共享资料给Wind ...

  4. Func,Action 的介绍

    Func,Action 的介绍 Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如在反射中 ...

  5. ASUS S46CB 刷BIOS

    1. 从ASUS官网下载要新的BIOS文件: 地址:https://www.asus.com.cn/Notebooks_Ultrabooks/S46CB/HelpDesk_Download/ 2. 开 ...

  6. linux安装bind with DLZ <NIOT>

    2015年6月11日 1.sudo wget ftp://ftp.isc.org/isc/bind9/9.10.1/bind-9.10.1.tar.gz  或者 使用“rz”命令 2.tar -zxv ...

  7. redis加入windows服务自启动

    今天研究了下redis,很简单 下载减压就可以用,但是自启动搞了好久! 直接sc create redis binPath = D:redis/redis-server.exe start = aut ...

  8. 大数据时代之hadoop(三):hadoop数据流(生命周期)

    了解hadoop,首先就需要先了解hadoop的数据流,就像了解servlet的生命周期似的.hadoop是一个分布式存储(hdfs)和分布式计算框架(mapreduce),但是hadoop也有一个很 ...

  9. 布局常见问题之css实现多行文本溢出显示省略号(…)全攻略

    省略号在ie中可以使用text-overflow:ellipsis了,但有很多的浏览器都需要固定宽度了,同时ff这些浏览器并不支持text-overflow:ellipsis设置了,下文来给各位整理一 ...

  10. 《Mastering Opencv ...读书笔记系列》车牌识别(II)

    http://blog.csdn.net/jinshengtao/article/details/17954427   <Mastering Opencv ...读书笔记系列>车牌识别(I ...