codeforces #140 dv2 A where do I turn
来源:互联网 发布:苹果微信网络连接失败 编辑:程序博客网 时间:2024/05/21 08:17
Codeforces #140 dv2 结题报告
A
这道题可以有多种方法求解 。
1.我使用了最笨的一种,是较丑的一种 就是分类讨论然后再用在讨论c点的位置 然后在讨论K的正负,,教笨;
2.学长使用的是象限方法讨论 因为确定了为直线关系,所以每个象限之间又会有不同的特性
3.最为快速的一种方法 使用的是向量积,来判断z轴向量的正负就可以判断左右转动。证明如下图所示。
下面是三种方法的代码
# include <stdio.h>int main(){int mark;__int64 a,b,c,d,e,f;double k,g; while(scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&d,&e,&f)!=EOF){if(0==(b-d)){if(a>c&&f>d){printf("RIGHT\n");continue;}else if(a>c&&f<d){printf("LEFT\n");continue;}if(a<c&&f>d){printf("LEFT\n");continue;}else if(a<c&&f<d){printf("RIGHT\n");continue;}else {printf("TOWARDS\n");continue;}}else if(0==(a-c)){if(d>b&&e<c){printf("LEFT\n");continue;}if(d>b&&e>c){printf("RIGHT\n");continue;}if(d<b&&e<c){printf("RIGHT\n");continue;}if(d<b&&e>c){printf("LEFT\n");continue;}elseprintf("TOWARDS\n");}else{if(((a-c)*(b-f))==((b-d)*(a-e))){printf("TOWARDS\n");continue;}k=(double)(b-d)/(a-c);g=(double)b-k*a;if((k*e+g-f)>0){mark=1;}else{mark=0;}if(k>0){if(d>b){if(!mark){printf("LEFT\n");continue;}else{printf("RIGHT\n");continue;}}else{if(!mark){printf("RIGHT\n");continue;}else{printf("LEFT\n");continue;}}}else{if(b>d){if(!mark){printf("LEFT\n");continue;}else{printf("RIGHT\n");continue;}}else{if(!mark){printf("RIGHT\n");continue;}else{printf("LEFT\n");continue;}}}}}return 0;}
#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; }
#include<cstdio> #include<cstring> #include<cmath> #include<set> #include<algorithm> using namespace std; #define LL long long struct point { LL x,y; } x[3]; LL crossProduct(point a,point b,point c)//向量 ac 在 ab 的方向 顺时针是正 { return (c.x-a.x)*(b.y-a.y)-(b.x - a.x)*(c.y-a.y); } int main() { for(int i=0; i<3; ++i) scanf("%I64d%I64d",&x[i].x,&x[i].y); if((x[2].y-x[1].y)*(x[1].x-x[0].x)==(x[1].y-x[0].y)*(x[2].x-x[1].x)) puts("TOWARDS"); else if(crossProduct(x[2],x[1],x[0])<0) puts("RIGHT"); else puts("LEFT"); return 0; }
- codeforces #140 dv2 A where do I turn
- CodeForces 227A Where do I Turn?
- Codeforces Round #140 (Div. 2) A. Where do I Turn?
- A. Where do I Turn?
- Codeforces 227A Where do I Turn?(代数)
- where do I turn?
- where do i belong
- Where do I belong
- Where Do I LOOK Now?
- Bonfire: Where do I belong
- Where do I store my custom configuration for a BizTalk solution
- FreeCodeCamp学习--Where do I belong
- I would like to learn PFC. Where Do I start?
- I want to learn Android Development, where do I start?
- Where do I find more information about XML?
- Where do I belong 重点:arr.sort(compareFunction)
- How do you turn a Mongoose document into a plain object?
- How do I create a MEX file
- 关于sql的执行计划(推荐详细)
- Visual Studio 2010——C#的CheckedListBox控件的使用
- android之布局控件
- BCB如何拦截消息
- NSDate 一些常用方法(待补充)
- codeforces #140 dv2 A where do I turn
- 遍历多重嵌套控件里面的控件
- Linux Shell编程--入门脚本
- Android学习之 点击事件
- PowerDesign-3物理数据模型-PDM)
- ldd 打印可执行文件依赖哪些共享库
- 引用:初探Sql Server 执行计划及Sql查询优化
- [在港学习工作] 一个应届MSc学生在香港的找工作心得
- 加载一个swf,