Codeforces 851 B Arpa and an exam about geometry

来源:互联网 发布:python classmethod 编辑:程序博客网 时间:2024/05/21 10:50

题目地址
题意:给你3个点的坐标,问在这个平面内能不能找到一个点,3个点围绕这个点同时选择同一角度,使得旋转以后a点在原来b点的位置,旋转以后b点在原来c点的位置。
思路:画图就会发现,只有当这三个点在同一个圆上面,并且ab==bc就是可以找到的。因为在圆上面等长的弦对应的弧是等长的,绕圆心旋转是一定能重合的。看下图:
这里写图片描述
然后因为是圆,所以不能为同一斜率,记住最好不要用double,因为如果你算长度的时候用了sqrt,可能精度就不好处理了。

#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#include <iomanip>#define N 1000010#define M 4000010#define LL __int64#define inf 0x7f7f7f7f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;LL solve(LL a, LL b, LL x, LL y) {    return (a - x)*(a - x) + (b - y)*(b - y);}bool check(LL a, LL b, LL c, LL d, LL e, LL f){    if ((d - b)*(e - c) == (f - d)*(c - a))         return 0;    return 1;}int main() {    cin.sync_with_stdio(false);    double ab, ac, bc;    LL ax, ay, bx, by, cx, cy;    while (cin >> ax >> ay >> bx >> by >> cx >> cy) {        if (solve(ax, ay, bx, by) == solve(bx, by, cx, cy) && check(ax, ay, bx, by, cx, cy)) {            cout << "Yes" << endl;        }        else {            cout << "No" << endl;        }    }    return 0;}
阅读全文
0 0
原创粉丝点击