Gym - 100187H(相似三角形判断)

题目:

Statements

Everyone probably heard the rumours about the constellation of Bermuda Triangle: any person who looks to this constellation of three stars is said to disappear completely. Though, it's not clear who then spreads these rumours.

Recently two photos have been sent to the editorial office of the newspaper you work on. Each photo depicts three glowing points on the dark background. The note applied to the photos indicates that they are the photos of the constellation of the Bermuda Triangle.

Of course, the editors cannot check if it's true without the risk of the stuff. But at least it is possible to make sure that each photo depicts the same triple of stars. Remember that photos could be taken with the different zoom and rotation. They could also be taken with the help of a mirror in order to decrease the risk of triggering the curse.

As a regular programmer of the newspaper you have the task to determine if these photos can depict the same triple of stars.

Input

The input consists of 6 lines. Each of the first three lines contains two integers separated by space — the coordinates of stars on the first photo. Each of the next three lines also contains two integers — the coordinates of stars on the second photo. All coordinates are between  - 104 and 104, inclusively. Stars on each photo don't coincide and don't lie on the same line.

Output

Output «YES» if the photos can depict the same triple of stars and «NO» otherwise.

Examples

Input

0 0
0 2
1 0
0 0
0 4
2 0

Output

YES

Input

0 0
0 2
1 0
0 0
0 4
3 0

Output

NO

Input

5 5
7 6
6 3
1 0
0 1
1 1

Output

YES

给出两个三角形的三个点的坐标,判断这两个三角形是不是相似三角形。

起初求的边的距离,开了平方根,然后计算取模的时候无法计算。所以就去了根号。

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#define LL long long
using namespace std;

struct node
{
    int x1,y1;
};
LL dist1[4];
LL dist2[4];
LL dist(node a,node b)
{
    return (a.x1-b.x1)*(a.x1-b.x1)+(a.y1-b.y1)*(a.y1-b.y1);
}
int main()
{
    node a1,b1,c1;
    node a2,b2,c2;
    scanf("%d%d",&a1.x1,&a1.y1);
    scanf("%d%d",&b1.x1,&b1.y1);
    scanf("%d%d",&c1.x1,&c1.y1);
    scanf("%d%d",&a2.x1,&a2.y1);
    scanf("%d%d",&b2.x1,&b2.y1);
    scanf("%d%d",&c2.x1,&c2.y1);
    dist1[0]=dist(a1,b1);
    dist1[1]=dist(a1,c1);
    dist1[2]=dist(b1,c1);
    dist2[0]=dist(a2,b2);
    dist2[1]=dist(a2,c2);
    dist2[2]=dist(b2,c2);
    sort(dist1,dist1+3);
    sort(dist2,dist2+3);
    int k = 0;
    for(int i = 0;i < 3;i ++)
        if(dist1[i]%dist2[i]==0||dist2[i]%dist1[i]==0)
            k++;
            if(k == 3)
        printf("YES\n");
        else printf("NO\n");
    return 0;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值