Codeforces Round #432 (Div. 2) B. Arpa and an exam about geometry(数学水题)

97 篇文章 0 订阅
17 篇文章 0 订阅

B. Arpa and an exam about geometry
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

Print "Yes" if the problem has a solution, "No" otherwise.

You can print each letter in any case (upper or lower).

Examples
input
0 1 1 1 1 0
output
Yes
input
1 1 0 0 1000 1000
output
No
Note

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.


题解:

比赛还在进行但是我已经写不动了,10分钟过a题(太水不想写题解),20分钟过b题。。c题看不懂,d题不会做,e题。。。算了吧,虽然这题很水但还是水一发博客

题意:

给你3个点的坐标,问你是否能找到一个点,以该点为中心旋转一定的角度使得a与b重合,b与c重合

思路:

直接判断只要两个线段长度相同而且三个点不在同一直线上就行了

ps:

这题之前用double型40组数据出错估计是因为double精度不够,还有就是斜率不存在的时候会出问题,把数据类型改成long long,把斜率判等写成乘法就好了

暂时ac的代码:

#include<iostream>
#include<cstring>
#include<stdio.h>
#include<math.h>
#include<string>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<deque>
#include<algorithm>
using namespace std;
#define INF 100861111
#define ll long long
#define eps 1e-7
#define maxn 20
int main()
{
    long long x1,y1,x2,y2,x3,y3,k1,k2,d1,d2;
    scanf("%lld%lld%lld%lld%lld%lld",&x1,&y1,&x2,&y2,&x3,&y3);
    d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);
    if(d1!=d2)
    {
        printf("No\n");
        return 0;
    }
    if((x2-x3)*(y1-y2)==(x1-x2)*(y2-y3))
    {
        printf("No\n");
    }
    else
        printf("Yes\n");
    return 0;
}





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值