天天看点

CodeForces 18A Triangle

Description

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

Input

The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3

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 Input

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

判断三角形是不是直角。简单枚举一下加勾股定理就好了

#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long LL;
const int low(int x){ return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int T, x[3], y[3], d[3];

int check()
{
  for (int i = 0; i < 3; i++)
  {
    d[i] = (x[i] - x[(i + 1) % 3])*(x[i] - x[(i + 1) % 3]) + (y[i] - y[(i + 1) % 3])*(y[i] - y[(i + 1) % 3]);
  }
  sort(d, d + 3);
  return d[0] && d[0] + d[1] == d[2];
}

int main()
{
  while (scanf("%d%d", &x[0], &y[0]) != EOF)
  {
    for (int i = 1; i < 3; i++) scanf("%d%d", &x[i], &y[i]);
    if (check()) { printf("RIGHT\n"); continue; }
    int flag = 0;
    for (int i = 0; i < 3; i++)
    {
      x[i]--; flag += check();
      x[i] += 2; flag += check();
      x[i]--; 
      y[i]--; flag += check();
      y[i] += 2; flag += check();
      y[i]--;
    }
    printf("%s\n", flag ? "ALMOST" : "NEITHER");
  }
  return 0;
}