A. Triangle

题目连接:

http://codeforces.com/contest/6/problem/A

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<bits/stdc++.h>
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;
}

最新文章

  1. Three.js资源
  2. Bitmap简单操作笔记
  3. zjuoj 3606 Lazy Salesgirl
  4. DIV+CSS例子
  5. Bootstrap组件On和Off语法
  6. XC文件管理器(Android应用)
  7. windows下使用批处理调用exe和服务
  8. iOS extern使用教程
  9. 【转】java jvm 线程 与操作系统线程
  10. ccf认证 201709-4 通信网络 java实现
  11. 从零开始:一个正式的vue+webpack项目的目录结构是怎么形成的
  12. php redis在windows下的部署
  13. 系统用户在Samba服务器中起一个别名
  14. 15款css3鼠标悬停图片动画过渡特效
  15. 接口测试工具-Jmeter使用笔记(三:管理请求服务器信息和Headers参数)
  16. windows 网卡配置的设置命令
  17. 【sping揭秘】3、Spring容器中bean默认是保持一个实例
  18. 局域网arpspoof欺骗获取cookie/图片/密码
  19. 第三方网站返回hybrid app H5页面缓存问题应对策略
  20. 微信小程序地图之逆地理编码

热门文章

  1. es6新语法Object.assign()
  2. perl6 登录phpmyadmin
  3. Django 自定义分页类
  4. 01布尔模型&amp;倒排索引
  5. SQLite3 安装、基本操作
  6. slave-&gt;pxc后GTID不一致
  7. 在ubuntu 上安装pycharm
  8. CentOS下NTP安装配置
  9. Codefroces 735D Taxes(哥德巴赫猜想)
  10. 「Ionic」WebStorm的使用錯誤-