atcoder#ABC239C. [ABC239C] Knight Fork

[ABC239C] Knight Fork

Score : 300300 points

Problem Statement

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

Notes

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

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

image

Constraints

  • 109x1109-10^9 \leq x_1 \leq 10^9
  • 109y1109-10^9 \leq y_1 \leq 10^9
  • 109x2109-10^9 \leq x_2 \leq 10^9
  • 109y2109-10^9 \leq y_2 \leq 10^9
  • (x1,y1)(x2,y2)(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:

x1x_1 y1y_1 x2x_2 y2y_2

Output

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

0 0 3 3
Yes
  • The distance between points (2,1)(2,1) and (x1,y1)(x_1, y_1) is (02)2+(01)2=5\sqrt{(0-2)^2 + (0-1)^2} = \sqrt{5};
  • the distance between points (2,1)(2,1) and (x2,y2)(x_2, y_2) is (32)2+(31)2=5\sqrt{(3-2)^2 + (3-1)^2} = \sqrt{5};
  • point (2,1)(2, 1) is a lattice point,

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

0 1 2 3
No

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

1000000000 1000000000 999999999 999999999
Yes

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