CodeForces 18A Triangle好暴力啊→_→
2015-07-30 08:35
309 查看
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 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 Input
Input
Output
Input
Output
Input
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 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 <iostream> #include<cstdio> using namespace std; struct po { int x,y; }point[4]; bool judge() { if(((point[0].x-point[1].x)*(point[0].x-point[1].x)+(point[0].y-point[1].y)*(point[0].y-point[1].y))&&((point[0].x-point[2].x)*(point[0].x-point[2].x)+(point[0].y-point[2].y)*(point[0].y-point[2].y))&&((point[1].x-point[2].x)*(point[1].x-point[2].x)+(point[1].y-point[2].y)*(point[1].y-point[2].y))) return true; return false; }//就是这里没写WA了两次T^T 自己能找到错误也是很开心的 int cos(po a,po b,po c) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.x-c.x)*(a.x-c.x)+(a.y-c.y)*(a.y-c.y)-(b.x-c.x)*(b.x-c.x)-(b.y-c.y)*(b.y-c.y); } int main() { // freopen("cin.txt","r",stdin); while(~scanf("%d%d%d%d%d%d",&point[0].x,&point[0].y,&point[1].x,&point[1].y,&point[2].x,&point[2].y)) { if(!cos(point[0],point[1],point[2])||!cos(point[1],point[2],point[0])||!cos(point[2],point[0],point[1])) { if(judge()) {printf("RIGHT\n"); continue;} } bool mark=0; for(int i=0;i<3;i++) { point[i].x++; if(!cos(point[0],point[1],point[2])||!cos(point[1],point[2],point[0])||!cos(point[2],point[0],point[1])) { if(judge()){ mark=1; break; } } point[i].x--;point[i].x--; if(!cos(point[0],point[1],point[2])||!cos(point[1],point[2],point[0])||!cos(point[2],point[0],point[1])) { if(judge()){ mark=1; break; } } point[i].x++;point[i].y++; if(!cos(point[0],point[1],point[2])||!cos(point[1],point[2],point[0])||!cos(point[2],point[0],point[1])) { if(judge()){ mark=1; break; } } point[i].y--;point[i].y--; if(!cos(point[0],point[1],point[2])||!cos(point[1],point[2],point[0])||!cos(point[2],point[0],point[1])) { if(judge()){ mark=1; break; } } point[i].y++; } if(!mark) printf("NEITHER\n"); if(mark) printf("ALMOST\n"); } return 0; }
相关文章推荐
- 同步定制 Unity团队 程序的C#文件模板
- UI_简单的NeonLignt
- UI_UIButton
- Qt实战之开发CSDN下载助手 (1)
- Google Protocol Buffer 的使用和原理
- 浅谈 System.Linq.Enumerable.AsEnumerable 方法
- Spring讲解------------SSH开发积分商城
- glpi+osc
- POJ 3984 迷宫问题
- arm mmu源码分析
- ArcGIS Desktop 10.1+ArcEngine10.1完全破解安装教程
- Scala界面事件处理编程实战
- Ant 执行 exec cmd.exe 时路径包含空格的问题
- android studio下使用android的日志api
- (4) SQL 语句 - 表基本操作
- UI_UILabel
- 课堂笔记06
- 嵌入式linux工程师面试题目C语言基础部分(问答题)
- UI_UIView
- UIButtom及其常用的小控件