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. 设计模式 -- 组合模式 (Composite Pattern)

    定义: 对象组合成部分整体结构,单个对象和组合对象具有一致性. 看了下大概结构就是集团总公司和子公司那种层级结构. 角色介绍: Component :抽象根节点:其实相当去总公司,抽象子类共有的方法: ...

  2. 跑github上的Symfony项目遇到的问题

    Loading composer repositories with package information Installing dependencies (including require-de ...

  3. ES 6 : 字符串的扩展

    1. 字符的Unicode表示法 JavaScript允许表示\u0000—\uFFFF之间的字符.超出这个范围,必须用2个双字节的形式表达.如:"\u20BB7"是汉字 &quo ...

  4. Ubuntu火狐、Chromium等浏览器安装flash插件

    1.打开系统设置->软件和更新->其他软件,勾选Canonical合作伙伴,输入密码,重新载入更新 2.打开终端,按装插件 sudo apt install adobe-flashplug ...

  5. 洛谷-求同构数的个数-NOIP2013提高组复赛

    题目描述 Description 所谓同构数是指这样的数,即它出现在它的平方数的右端.例如,5的平方是25 (即5×5=25),5是25右端的数,那么5就是同构数.又如,25的平方是625(即25×2 ...

  6. sharepoint:基于AD的FORM认证

    //来源:http://www.cnblogs.com/jindahao/archive/2012/05/07/2487351.html 需求: 1. 认证要基于AD 2. 登入方式要页面的方式(fo ...

  7. Tiny64140之初始化时钟

    简介: Tiny6410 时钟逻辑为整个芯片提供了3种时钟分别为FCLK.HCLK.PCLK有三个PLL 分别为APLL.MPLL.EPLL.   APLL 专用于CPU   MPLL 供AHB(存储 ...

  8. gridview XML

    GridView动态添加模板列   http://blog.csdn.net/wljhk2006/article/details/24723219 XML与DataTable互转类 http://bl ...

  9. oracle中110个常用函数介绍

    1. ASCII 返回与指定的字符对应的十进制数; SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dua ...

  10. DEV TdxLayoutGroup设置tab

    TdxLayoutGroup 属性的 LayoutDirection :ldvertical,ldtabbed(显示tab页),ldhorizontal