codeforces 851B Arpa and an exam about geometry
来源:互联网 发布:2015中国国际储备数据 编辑:程序博客网 时间:2024/06/14 23:07
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).
0 1 1 1 1 0
Yes
1 1 0 0 1000 1000
No
In the first sample test, rotate the page around (0.5, 0.5) by .
In the second sample test, you can't find any solution.
题意:给定a,b,c三个点,求是否存在一个点d使a绕d旋转一定角度与b重合,b绕d旋转相同角度与c重合
因为a,b,c的位置使固定的且a,b,c不重合,要满足这个条件判断a,b,c不在一条直线上且Lab=Lbc(可以画图证明),因为数据较大,计算长度相等是相乘可能爆int
#pragma comment(linker,"/STACK:1024000000,1024000000")#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<stack>#include<queue>#include<deque>#include<set>#include<map>#include<cmath>#include<vector>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> PII;#define pi acos(-1.0)#define eps 1e-10#define pf printf#define sf scanf#define lson rt<<1,l,m#define rson rt<<1|1,m+1,r#define ess tree[rt]#define _s second#define _f first#define all(x) (x).begin,(x).end#define mem(i,a) memset(i,a,sizeof i)#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)#define mi ((l+r)>>1)#define sqr(x) ((x)*(x))const int inf=0x3f3f3f3f;ll a,b,c,d,e,f;ll length(ll a,ll b,ll c,ll d){ return sqr(a-c)+sqr(b-d);//不用返回double,计算平方和是否相等即可}bool check(ll a,ll b,ll c,ll d,ll e,ll f){ if((d-b)*(e-c)==(f-d)*(c-a))//计算斜率相等用乘法,防止除数为0 return 0; return 1;}int main(){ while(~sf("%I64d%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&d,&e,&f)) { if(length(a,b,c,d)==length(c,d,e,f)&&check(a,b,c,d,e,f)) puts("Yes"); else puts("No"); } return 0;}
- codeforces 851B Arpa and an exam about geometry
- codeforces 851 B. Arpa and an exam about geometry
- Codeforces 851 B Arpa and an exam about geometry
- Codeforces Round #432 B. Arpa and an exam about geometry
- Codeforces Round#432 B. Arpa and an exam about geometry
- Codeforces Round #432 B. Arpa and an exam about geometry
- B. Arpa and an exam about geometry
- codeforce 851 B Arpa and an exam about geometry(思路)
- Codeforces 851B && Round #432 Div. 2 B. Arpa and an exam about geometry
- Codeforces 851B. Arpa and an exam about geometry 计算几何,结论题
- Div#432B Arpa and an exam about geometry
- Codeforces Round #432 Div2 B. Arpa and an exam about geometry
- codeforces Div#432 B Arpa and an exam about geometry(技巧)
- Codeforces Round #432 (Div. 2) B Arpa and an exam about geometry
- Codeforces Round #432 (Div. 2) B. Arpa and an exam about geometry(数学水题)
- codeforces Round4 B. Before an Exam
- Codeforces 4B Before an Exam
- codeforces 4B Before an Exam
- Java-链式栈
- 有头双链表的创建
- 正则表达式
- netbeans调试快捷键
- 运用if-else判断是否为闰年
- codeforces 851B Arpa and an exam about geometry
- Android 动画的介绍和实现
- PAT甲级 1006. Sign In and Sign Out (25)
- [NLP技术]关键词提取算法-TextRank
- 深度学习入门---只要300页ppt就够了!!!
- view的执行过程,各种方法的调用先后顺序
- OpenGL ES 2.0 VBO与渲染
- Python中的if-else
- jquery源码--extend函数的归纳