10250 The Other Two Trees
来源:互联网 发布:淘宝商家运作流程图 编辑:程序博客网 时间:2024/06/05 04:51
这道题乍看之下有些困难,其实题目的意思是告诉两个点的坐标,以这两个点连线作为直径画一个圆,然后求圆上面另外两个点连线过圆心且连线和前面的直径垂直。
我的做法是首先求出两个点的中心点,然后平移中心点坐标到原点,题目告诉的两个点也一样平移,假设移动之后两个点中有一个点的坐标为(a,b),那么所求的点平移之后的坐标就分别为(b,-a)和(-b,a),这个根据两向量垂直其向量内积为零以及向量的长度的公式结合起来就可以得到证明,然后把球出来的两个坐标根据前面的平移量再平移回去就行了。
#include <stdio.h>void func(double x1, double y1, double x2, double y2){double x_shift, y_shift;double a, b;double x3, y3, x4, y4;if(x1==x2 && y1==y2){printf("Impossible.\n");return;}x_shift = (x1+x2)/2.0;y_shift = (y1+y2)/2.0;a = x2-x_shift;b = y2-y_shift;x3 = b; y3 = -a;x4 = -b; y4 = a;x3 += x_shift;y3 += y_shift;x4 += x_shift;y4 += y_shift;printf("%.10lf %.10lf %.10lf %.10lf\n", x3, y3, x4, y4);}int main(void){double x1, y1, x2, y2;while(scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2) != EOF){func(x1, y1, x2, y2);}return 0;}
- 10250 - The Other Two Trees
- 10250 - The Other Two Trees
- 10250 The Other Two Trees
- 10250 - The Other Two Trees
- The Other Two Trees
- The Other Two Trees
- uva 10250 - The Other Two Trees
- uva-10250-The Other Two Trees
- Uva 10250 - The Other Two Trees
- uva 10250 - The Other Two Trees
- uva 10250 - The Other Two Trees
- UVA 10250 The Other Two Trees
- uva 10250 - The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVa 10250 The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVA 10250 The Other Two Trees
- 纪念第一篇博客
- 使用PowerDesigner创建数据库表图文并茂版
- 求绝对值函数abs()到底应该包含哪个头文件
- 困惑:单元测试该在什么时候写?
- 柔性数组
- 10250 The Other Two Trees
- linux下命令行
- 软件代码数字签名基本原理
- 直觉和品位: 转载《关于Git的主要维护者滨野纯的访谈》
- VB.Net程序设计:拖放Datagridview到另外一个Datagridview基本操作
- An overview of Openvswitch implementation
- hdu 4768
- High Performance Heterogeneous Container
- Intellij IDEA 12 主题和字体