102392: [AtCoder]ABC239 C - Knight Fork

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

On an $xy$-coordinate plane, is there a lattice point whose distances from two lattice points $(x_1, y_1)$ and $(x_2, y_2)$ are both $\sqrt{5}$?

Notes

A point on an $xy$-coordinate plane whose $x$ and $y$ coordinates are both integers is called a lattice point.
The distance between two points $(a, b)$ and $(c, d)$ is defined to be the Euclidean distance between them, $\sqrt{(a - c)^2 + (b-d)^2}$.

The following figure illustrates an $xy$-plane with a black circle at $(0, 0)$ and white circles at the lattice points whose distances from $(0, 0)$ are $\sqrt{5}$. (The grid shows where either $x$ or $y$ is an integer.)

image

Constraints

  • $-10^9 \leq x_1 \leq 10^9$
  • $-10^9 \leq y_1 \leq 10^9$
  • $-10^9 \leq x_2 \leq 10^9$
  • $-10^9 \leq y_2 \leq 10^9$
  • $(x_1, y_1) \neq (x_2, y_2)$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$x_1$ $y_1$ $x_2$ $y_2$

Output

If there is a lattice point satisfying the condition, print Yes; otherwise, print No.


Sample Input 1

0 0 3 3

Sample Output 1

Yes
  • The distance between points $(2,1)$ and $(x_1, y_1)$ is $\sqrt{(0-2)^2 + (0-1)^2} = \sqrt{5}$;
  • the distance between points $(2,1)$ and $(x_2, y_2)$ is $\sqrt{(3-2)^2 + (3-1)^2} = \sqrt{5}$;
  • point $(2, 1)$ is a lattice point,

so point $(2, 1)$ satisfies the condition. Thus, Yes should be printed.
One can also assert in the same way that $(1, 2)$ also satisfies the condition.


Sample Input 2

0 1 2 3

Sample Output 2

No

No lattice point satisfies the condition, so No should be printed.


Sample Input 3

1000000000 1000000000 999999999 999999999

Sample Output 3

Yes

Point $(10^9 + 1, 10^9 - 2)$ and point $(10^9 - 2, 10^9 + 1)$ satisfy the condition.

Input

题意翻译

在平面直角坐标系上有两个点,第 $i$ 个点的坐标为 $(x_i,y_i)$ 。现在依次输入 $x_1,y_1,x_2,y_2$ ,问:是否存在一个点,使得这个点与前文所述的两个点的距离都是 $\sqrt5$ ?

Output

分数:300分

问题描述

在二维直角坐标系中,是否存在一个格点,它与两个格点$(x_1, y_1)$和$(x_2, y_2)$的距离都为$\sqrt{5}$?

注释

在二维直角坐标系中,x坐标和y坐标都是整数的点叫做格点。

两点$(a, b)$和$(c, d)$之间的距离定义为它们之间的欧几里得距离,即$\sqrt{(a - c)^2 + (b-d)^2}$。

下图是一个二维直角坐标系,黑色圆圈在$(0, 0)$,白色圆圈在$(0, 0)$距离为$\sqrt{5}$的格点上(网格显示了x或y是整数的地方)。

image

约束

  • $-10^9 \leq x_1 \leq 10^9$
  • $-10^9 \leq y_1 \leq 10^9$
  • $-10^9 \leq x_2 \leq 10^9$
  • $-10^9 \leq y_2 \leq 10^9$
  • $(x_1, y_1) \neq (x_2, y_2)$
  • 输入中的所有值都是整数。

输入

输入格式如下:

$x_1$ $y_1$ $x_2$ $y_2$

输出

如果存在满足条件的格点,打印Yes;否则,打印No


样例输入1

0 0 3 3

样例输出1

Yes
  • 点$(2,1)$与$(x_1, y_1)$之间的距离为$\sqrt{(0-2)^2 + (0-1)^2} = \sqrt{5}$;
  • 点$(2,1)$与$(x_2, y_2)$之间的距离为$\sqrt{(3-2)^2 + (3-1)^2} = \sqrt{5}$;
  • 点$(2, 1)$是格点,

所以点$(2, 1)$满足条件。因此,应该打印Yes
同样可以断言$(1, 2)$也满足条件。


样例输入2

0 1 2 3

样例输出2

No

不存在满足条件的格点,所以应该打印No


样例输入3

1000000000 1000000000 999999999 999999999

样例输出3

Yes

点$(10^9 + 1, 10^9 - 2)$和点$(10^9 - 2, 10^9 + 1)$满足条件。

加入题单

上一题 下一题 算法标签: