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;
}

Codeforces Beta Round #6 (Div. 2 Only) A. Triangle 水题的更多相关文章

  1. Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon 水题

    A. Watermelon 题目连接: http://www.codeforces.com/contest/4/problem/A Description One hot summer day Pet ...

  2. Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题

    C. Four Segments 题目连接: http://codeforces.com/contest/14/problem/C Description Several months later A ...

  3. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  4. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  5. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  6. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  7. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  9. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

随机推荐

  1. docker ubuntu容器更换阿里源(转)

    问题:使用docker 利用下载的ubuntu镜像启动容器时,使用的源下载更新软件的速度较慢. 解决这个问题的方法是跟新ubuntu容器的源 示例:以ubuntu为基础镜像 启动一个名称为 test0 ...

  2. 面试中关于Java虚拟机(jvm)的问题看这篇就够了

    最近看书的过程中整理了一些面试题,面试题以及答案都在我的文章中有所提到,希望你能在以问题为导向的过程中掌握虚拟机的核心知识.面试毕竟是面试,核心知识我们还是要掌握的,加油~~~ 下面是按jvm虚拟机知 ...

  3. sqlmap tamper编写

    #!/usr/bin/env python """ Copyright (c) 2006-2017 sqlmap developers (http://sqlmap.or ...

  4. CTF AWD模式攻防Note

    ###0x01 AWD模式 Attack With Defence,简而言之就是你既是一个hacker,又是一个manager.比赛形式:一般就是一个ssh对应一个web服务,然后flag五分钟一轮, ...

  5. tp 框架 利用反射实现对象调用方法

    <?php class Person{ public $name="xiaoming"; function say(){ echo "i am ".$th ...

  6. ftp--vsftp\pureftpd

    FTP是File Transfer Protocol(文件传输协议),用于Internet上的控制文件的双向传输. 现今常用在一个局域网内,如学校.公司等一个指定范围的区域.(因为太过于简单和不安全) ...

  7. 机器学习-sklearn-learn

    随即森林 from sklearn import neighbors, datasets, preprocessing from sklearn.model_selection import trai ...

  8. Ecshop二次开发修改

    所有的错误,根据下面这个帖子修改 http://bg.artuion.com/328.html 修改错误: 第300行 原有内容: //return preg_replace("/{([^\ ...

  9. css 资料链接

    https://tink.gitbooks.io/fe-collections/content/ch03-css/float.html https://css-tricks.com/almanac/p ...

  10. 洛谷 P1469 找筷子 题解

    题目传送门 先排序一遍,再一个一个判断是否有偶数个.注意for循环要i+=2. #include<bits/stdc++.h> using namespace std; ]; int ma ...