Codeforces851B
来源:互联网 发布:元数据和数据字典 编辑:程序博客网 时间:2024/04/20 05:30
Arpa is taking a geometry exam. Here is the last problem of the exam.
You are given three points a, b, c.
Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.
Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.
The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.
Print "Yes" if the problem has a solution, "No" otherwise.
You can print each letter in any case (upper or lower).
题目大意:给定三个点a,b,c,问是否存在绕任意一点旋转任意角度后是否满足a点在原来b点的位置,b点在原来c点的位置。
分析:其实就是判断a,b,c是不是一个等腰三角形的问题,因为如果b在ac的垂直平分线上,那么经过一定旋转后必然可以满足
题意,同时要注意a,b,c不能在同一直线上。
我在这一题上的坑点主要是浮点数大小比较..又忘了怎么比较,还有计算过程中数据溢出,在数学题中一定要注意这些问题。
#include<bits/stdc++.h>using namespace std;const double eps=1e-6;int main(){ int ax,ay,bx,by,cx,cy; cin>>ax>>ay>>bx>>by>>cx>>cy; long double midx=(ax+cx)*1.0/2,midy=(ay+cy)*1.0/2; long double len=fabs(ax-midx)*fabs(ax-midx)+fabs(ay-midy)*fabs(ay-midy); long double len2=fabs(bx-midx)*fabs(bx-midx)+fabs(by-midy)*fabs(by-midy); long double len3=fabs(ax-bx)*fabs(ax-bx)+fabs(ay-by)*fabs(ay-by); //cout<<len<<" "<<len2<<" "<<len3<<endl; if(len2==0) { cout<<"No"<<endl; return 0; } if(fabs(len+len2-len3)<eps) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0;}
- Codeforces851B
- HDOJ HDU 1016 Prime Ring Problem
- SGBM学习记录(一)
- 20:球弹跳高度的计算
- CentOS7.2安装ActiveMQ全过程
- 蜂窝移动的架构 以及省电的方法
- Codeforces851B
- Linux下几款C++程序中的内存泄露检查工具
- C 位级操作
- [LeetCode]20. Valid Parentheses
- Java web学习总结2:Tomcat服务器的学习和使用
- 进程中的用户堆栈、内核栈
- LeetCode 27. Remove Element
- gitlab常用维护命令
- Vue中的父子组件通讯以及使用sync同步父子组件数据