CodeForces #140 (Div. 2)-A.
来源:互联网 发布:淘宝药店哪家好 编辑:程序博客网 时间:2024/06/06 03:29
A . Where do I Turn ?
题意:平面上有三个点A,B,C,已知AB两点连成一条直线,C点要么在直线AB上,要么就与直线AB垂直。已知初始方向是从A到B的方向并且位于B点上,求C点是向左还是直走还是向右。
思路:先排除三点在一条直线上的情况,再分四个情况分别分析左右方向。
AC代码:
#include <stdio.h>#include <stdlib.h>using namespace std;int main(){ __int64 x1,y1,x2,y2,x3,y3; while(scanf("%I64d %I64d", &x1, &y1)!=EOF) { scanf("%I64d %I64d", &x2, &y2); scanf("%I64d %I64d", &x3, &y3); if( (x2-x1)*(y3-y2)==(y2-y1)*(x3-x2) ) { printf("TOWARDS\n"); } else { if(x2-x1>=0 && y2-y1>0) { if(x3-x2>0) printf("RIGHT\n"); else printf("LEFT\n"); } else if(x2-x1<=0 && y2-y1<0) { if(x3-x2>0) printf("LEFT\n"); else printf("RIGHT\n"); } else if(x2-x1<0 && y2-y1>=0) { if(y3-y2>0) printf("RIGHT\n"); else printf("LEFT\n"); } else if(x2-x1>0 && y2-y1<=0) { if(y3-y2>0) printf("LEFT\n"); else printf("RIGHT\n"); } } } return 0;}
- CodeForces #140 (Div. 2)-A.
- CodeForces #176(Div.2)-A
- Codeforces 434 Div. 2 A
- codeforces #320 div 2A
- Codeforces--447Div.2--A
- Codeforces #284 (Div.1 A~E & Div.2 A~E)
- 【CodeForce】Codeforces Round #140 (Div. 2) A B C
- Codeforces Round #140 (Div. 2) A. Where do I Turn?
- Cards(Codeforces 701A)(Codeforces Round #364Div.2 A)
- codeForces #140 div 2
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- JAVA解析生成JSON相关
- CF 287B(Pipeline-二分)
- poj 2337
- java Data 类
- c语言程序设计第三次作业 2
- CodeForces #140 (Div. 2)-A.
- 03-23 11:12:21.286: E/MediaPlayer(666): error (1, -2147483648)出现的一种情况
- JS 解析JSON
- QQ的数据分析
- image processing with MATLAB
- java中Thread和Runnable的介绍
- Oracle还原已删除的表数据
- 黑马程序员 笔记(十二)——String、StringBuffer、StringBulider
- gps、基站、wifi 实现谷歌地图定位