UVA - 10250 The Other Two Trees
来源:互联网 发布:mac苹果商店无法连接 编辑:程序博客网 时间:2024/06/06 10:42
题目大意:给出两棵树的位置找到另外两棵,四点构成正方形。
构成正方形证明:侵删。UVa 10250 The Other Two Trees by 我叫空格_
解题思路:求出中点,把所给的两棵树的坐标绕中点旋转 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>#include<cstring>#include<cstdlib>#include<cmath>using namespace std;int main() { double x1, y1, x2, y2; while(scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF) { 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; }
1 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
- UVA - 10879 Code Refactoring
- Java中List和ArrayList的区别
- JAVA: List用法
- java整型byte,short,int,long取值范围大小
- sql server 与 mysql在自定以数据类型的区别
- UVA - 10250 The Other Two Trees
- 线程同步引发的安全问题
- 线程之间的通信
- 模拟售票
- 线程死锁
- 自动装箱和拆箱所带来的问题(1)“==”问题
- js 中对象--对象结构(原型链基础解析)
- C/s模式与B/S模式
- 20160712常规赛总结