Uva 10250 The Other Two Trees
来源:互联网 发布:推荐好用的精华液知乎 编辑:程序博客网 时间:2024/06/08 11:26
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1191
题意:有一个平行四边形然后分别以四条边为边长向外作正方形,四棵树在四个正方形中心的位置。其实四棵树构成正方形,相当于给出正方形的对角线的两个点,求另外两个。
证明正方形如下:来源:http://m.blog.csdn.net/blog/u014491224/29647971
下面证△FOE≌△HGO
设CD=2a,BC=2b
∴EF=OH=a,
OF=HG=b
易知∠DFO=∠OHB
∴∠EFO=∠OHG=∠DFO+90°
∴△FOE≌△HGO(边角边)
∴∠E=∠GOH
∠EOG=∠EOF+∠DFO+∠E=90° (因为再加上∠DFE就等于内角和180°了)
综上,OE=OG且OE⊥OG
由于对称性,四棵树就构成了个正方形。
需要注意pi
代码:
#include<cstdio>#include<cmath>#include<iostream>using namespace std;const double pi=acos(-1);const double eps=1e-10;double cmp(double x){ if(fabs(x)<eps) return 0; else return x;}struct Point{ double x,y; Point(double x,double y):x(x),y(y){};};typedef Point Vector;Vector Rotate(Vector a,double rad){ return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));}Vector reduce(Vector a,double time){ return Vector(a.x*time,a.y*time);}int main(){ double x1,x2,y1,y2; while(cin>>x1>>y1>>x2>>y2) { Vector hypo(x2-x1,y2-y1); Vector v=reduce(hypo,sqrt(2)/2); Vector v1=Rotate(v,pi/4); Vector v2=Rotate(v,-pi/4); //cout<<v1.x<<" "<<v1.y<<" "<<v2.x<<" "<<v2.y<<endl; Vector ans1(cmp(v1.x+x1),cmp(v1.y+y1)); Vector ans2(cmp(v2.x+x1),cmp(v2.y+y1)); printf("%.10lf %.10lf %.10lf %.10lf\n",ans1.x,ans1.y,ans2.x,ans2.y); //cout<<ans1.x<<" "<<ans1.y<<" "<<ans2.x<<" "<<ans2.y<<endl; } 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
- 面向对象原则之里氏替换原则
- iOS IPV6 审核
- 51nod 1486 大大走格子
- Spring与MyBatis整合 、Spring整合MyBatis应用
- 1049. 数列的片段和(20)
- Uva 10250 The Other Two Trees
- Image Load Events——图像加载事件
- Vue.extend()构造器
- ORACLE 10g 第一课 绪论 安装及体系结构概述
- setInterval和setTimeOut
- 微信样式库使用
- Cocos2d-x 3.x lua中的定时器
- JavaWeb中的Servlet概述
- 2017.7.5(转)—【学习笔记】python2的print和python3的print()