MOVEMENT - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

You’re standing at (0, 0), and will make the following four movements:

  • A steps in the positive X direction.
  • B steps in the positive Y direction.
  • C steps in the negative X direction.
  • D steps in the negative Y direction.

Find your final coordinates.

EXPLANATION:

The changes in X and Y coordinates are independent of each other.
So,

  • The final X coordinate is A steps positive, C steps negative, so it’s A-C.
  • The final Y coordinate is B steps positive, D steps negative, so it’s B-D.

The solution is hence to output A-C and B-D, separated by a space.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
a, b, c, d = map(int, input().split())
print(a-c, b-d)