A. Triangle

A. Triangle
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.

Input

The first input line contains 6 space-separated integers x1,?y1,?x2,?y2,?x3,?y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.

Output

If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, outputNEITHER.

Sample test(s)
input
0 0 2 0 0 1
output
RIGHT
input
2 3 4 5 6 6
output
NEITHER
input
-1 0 2 0 0 1
output
ALMOST
v退化三角形和三角形的判断
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;

bool cmp(int a,int b){
return a>b;
}
pair<int,int >p[4];
int dir[4][2]={1,0,0,1,0,-1,-1,0};
int line(int a,int b,int c,int d){
return (a-c)*(a-c)+(d-b)*(d-b);
}
int arr[3];
int judge(int x1,int y1,int x2,int y2,int x3,int y3){
if(x1==x2&&y1==y2)return 0;
if(x2==x3&&y2==y3)return 0;
if(x1==x3&&y1==y3)return 0;
arr[0]=line(x1,y1,x2,y2);
arr[1]=line(x1,y1,x3,y3);
arr[2]=line(x2,y2,x3,y3);
sort(arr,arr+3);
if(arr[2]==arr[1]+arr[0])
return 1;
return 0;
}

int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int x1,y1,x2,y2,x3,y3;
while(cin>>p[1].first>>p[1].second>>p[2].first>>p[2].second>>p[3].first>>p[3].second){
if(judge(p[1].first,p[1].second,p[2].first,p[2].second,p[3].first,p[3].second)){
cout<<"RIGHT";return 0;
}
else{
for(int i=0;i<4;i++){
int nx=p[1].first+dir[i][0];
int ny=p[1].second+dir[i][1];
if(judge(nx,ny,p[2].first,p[2].second,p[3].first,p[3].second)){
cout<<"ALMOST";return 0;
}
}
for(int i=0;i<4;i++){

int nx=p[2].first+dir[i][0];
int ny=p[2].second+dir[i][1];
if(judge(p[1].first,p[1].second,nx,ny,p[3].first,p[3].second)){

cout<<"ALMOST";return 0;
}
}
for(int i=0;i<4;i++){

int nx=p[3].first+dir[i][0];
int ny=p[3].second+dir[i][1];
if(judge(p[1].first,p[1].second,p[2].first,p[2].second,nx,ny)){
cout<<"ALMOST";return 0;
}
}
}
cout<<"NEITHER";
}
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
/*****************************************************************************/ /* */ /* 888888888 ,o, / 888 */ /* 888 88o88o " o8888o 88o8888o o88888o 888 o88888o */ /* 888 888 888 88b 888 888 888 888 888 d888 88b */ /* 888 888 888 o88^o888 888 888 "88888" 888 8888oo888 */ /* 888 888 888 C888 888 888 888 / 888 q888 */ /* 888 888 888 "88o^888 888 888 Cb 888 "88oooo" */ /* "8oo8D */ /* */ /* A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. */ /* (triangle.c) */ /* */ /* Version 1.6 */ /* July 28, 2005 */ /* */ /* Copyright 1993, 1995, 1997, 1998, 2002, 2005 */ /* Jonathan Richard Shewchuk */ /* 2360 Woolsey #H */ /* Berkeley, California 94705-1927 */ /* jrs@cs.berkeley.edu */ /* */ /* This program may be freely redistributed under the condition that the */ /* copyright notices (including this entire header and the copyright */ /* notice printed when the `-h' switch is selected) are not removed, and */ /* no compensation is received. Private, research, and institutional */ /* use is free. You may distribute modified versions of this code UNDER */ /* THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE */ /* SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE */ /* AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR */ /* NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as */ /* part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT */ /* WITH THE AUTHOR. (If you are not directly supplying this code to a */ /* customer, and you are instead telling them how they can obtain it for */ /* free, then you are not required to make any arrangement with me.)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值