UVA-10250 The Other Two Trees
来源:互联网 发布:墨客网络 编辑:程序博客网 时间:2024/06/05 20:12
2016-08-12
UVA - 10250 The Other Two Trees
题目大意:给出两棵树的位置找到另外两棵,四点构成正方形。
解题思路:求出中点,把所给的两棵树的坐标绕中点旋转 90 度得到的坐标就是另外两棵。
(x, y) 绕 (0, 0) 顺时针转90度后坐标为 (y, -x);
(x, y) 绕 (p, q) 顺时针转90度;
先把 (p, q) 移到原点,化为求 (x-p, y-q) 绕 (0, 0)旋转 90 度,即 (y-q, p-x);
再移回原位,最终 (y-q+p, p-x+q)。
#include <iostream>#include <cstdio>using namespace std;int main() {double x1, y1, x2, y2;while ( ~scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) ) {double x3, y3, x4, y4;double x = (x1 + x2) / 2;double y = (y1 + y2) / 2;x3 = y1 - y + x;y3 = x - x1 + y;x4 = y2 - y + x;y4 = x - x2 +y;printf("%.10lf %.10lf %.10lf %.10lf\n", x3, y3, x4, y4);}return 0;}
0 0
- 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
- 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
- ajax简单封装
- Opencv+Zbar二维码识别(二维码校正)
- 209. Minimum Size Subarray Sum(很重要)
- 8.12GDOI模拟赛总结
- android handler机制
- UVA-10250 The Other Two Trees
- Leetcode Maximum Depth of Binary Tree
- 调试机制
- UVA-408 Uniform Generator
- 很多C编译不支持bool型,导致出现false和true未定义
- box-shadow投影
- HDU 1008 Elevator 水题
- 很高兴加入CSDN,与大家共同学习
- JavaSE自学笔记整理(七)