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. 17 - 路径操作-shutil模块

    目录 1 路径操作 1.1 os.path模块 1.2 pathlib模块 1.2.1 目录操作 1.2.2 文件操作 1.3 os 模块 2 shutil模块 2.1 copy复制 2.2 rm删除 ...

  2. jenkins+docker持续集成实验

    在互联网时代,对于每一家公司,软件开发和发布的重要性不言而喻,目前已经形成一套标准的流程,最重要的组成部分就是持续集成(CI)及持续部署.交付(CD).本文基于Jenkins+Docker+Git实现 ...

  3. 洛谷 P1296奶牛的耳语 题解

    题目传送门 这道题很显然可以用O(n2)的方法来做(记得排序),由于数据较水...但还是在for循环中加一些优化:++i,据说这样会快一些... #include<bits/stdc++.h&g ...

  4. WordPress插件:WP No Category Base 去除分类Category目录

    不少折腾WordPress的朋友都希望去掉分类链接中的 /category/ 目录标志,网上很多这方面的教程,据倡萌所知,除了使用 WP No Category Base 插件(或类似插件),其他的方 ...

  5. MYSQL-----IFNULL()函数的用法

    Mysql查询中可以使用IFNULL()函数,IFNULL函数中有两个参数,它的作用是测试如果ifnull第一个参数不为null,就会显示出查询的结果,如果第一个参数为null,则会返回第二个参数的字 ...

  6. 邀请用户进TestFlight 体验 App 的测试版本

    iphone手机用户,在工作中常见到,APP版本现在是Beta阶段(iOS版本),需要邀请一些用户来体验新版本,在版本上线前提出更好的建议及时进行修改,此时用到了testflight,很方便的通过邀请 ...

  7. 深入理解计算机系统项目之 Shell Lab

    博客中的文章均为meelo原创,请务必以链接形式注明本文地址 Shell Lab是CMU计算机系统入门课程的一个实验.在这个实验里你需要实现一个shell,shell是用户与计算机的交互界面.普通意义 ...

  8. day3 作业

    文件操作用户很广泛,我们经常对文件进行操作: global log 127.0.0.1 local2 daemon maxconn log 127.0.0.1 local2 info defaults ...

  9. vue 分页插件

    有个小问题就是最多显示3个分页,可以手动改一下配置参数就好.直接代码: <template> <div class="pageination_align"> ...

  10. eclipse svn 以一种访问权限不允许的方式做了一个访问套接字的尝试

    以一种访问权限不允许的方式做了一个访问套接字的尝试 svn: Unable to connect http://xxx.xxx 安装插件是把Eclipse的网络访问禁止了,然后用svn就老提示[以一种 ...