Statistics

Problem Statement for "Rendezvous"

Problem Statement

In the game of Rendezvous, two pieces move on a two-dimensional grid. Both pieces are restricted to integer coordinates. The target piece begins at coordinates (x,y), and the seeker piece begins at coordinates (0,0). On every turn the target piece moves dx units horizontally and dy units vertically. Similarly, the seeker piece moves DX units horizontally and DY units vertically on every turn. For example, at the end of the first turn, the target piece is at coordinates (x+dx,y+dy) and the seeker piece is at coordinates (0+DX,0+DY). The values of dx, dy, DX, and DY are limited to integers between -1000 and 1000, inclusive.

You control the movement of the seeker piece. In other words, you choose the values of DX and DY. Your goal is to make the seeker piece rendezvous with the target piece in the minimum number of turns. A rendezvous occurs when both pieces end a turn at the same coordinates.

Create a class Rendezvous with a method interceptVector that takes ints x, y, dx, and dy and returns the integers DX and DY (in that order) as a int[]. If no rendezvous is possible, return the empty int[].

Definition

Class:
Rendezvous
Method:
interceptVector
Parameters:
int, int, int, int
Returns:
int[]
Method signature:
int[] interceptVector(int x, int y, int dx, int dy)
(be sure your method is public)

Notes

  • Given the input constraints, if the seeker cannot catch the target within 10000 turns, it will never catch the target.

Constraints

  • x and y are between -10000 and 10000, inclusive, but are not both 0.
  • dx and dy are between -1000 and 1000, inclusive.

Examples

  1. 500

    300

    55

    33

    Returns: { 555, 333 }

    Pieces meet at the end of the first turn.

  2. 500

    300

    600

    700

    Returns: { 850, 850 }

    Pieces meet at the end of the second turn.

  3. 1

    1

    1000

    1000

    Returns: { }

    The seeker piece can never catch the target piece.

  4. 9519

    -1002

    857

    -534

    Returns: { 914, -540 }

  5. -1024

    333

    15

    -186

    Returns: { }

  6. 0

    3988

    500

    0

    Returns: { 500, 997 }

  7. 1000

    1001

    0

    0

    Returns: { }

  8. 10000

    -10000

    999

    -999

    Returns: { 1000, -1000 }

  9. 1011

    337

    -3

    902

    Returns: { 0, 903 }

  10. 2000

    1000

    -999

    -999

    Returns: { 1, -499 }

  11. 1

    2

    3

    4

    Returns: { 4, 6 }

  12. 79

    -80

    -79

    80

    Returns: { 0, 0 }

  13. -2343

    978

    1

    126

    Returns: { -780, 452 }

  14. 9999

    -9997

    997

    -999

    Returns: { }

  15. 3145

    5926

    535

    879

    Returns: { }

  16. 9967

    0

    -4

    -567

    Returns: { -3, -567 }

  17. 555

    3441

    986

    -46

    Returns: { 991, -15 }

  18. -500

    -400

    -1000

    -1000

    Returns: { }

  19. 78

    1078

    15

    -1000

    Returns: { 93, 78 }

  20. 983

    977

    16

    -4

    Returns: { 999, 973 }

  21. 0

    1

    1

    0

    Returns: { 1, 1 }

  22. 10000

    10000

    1

    1

    Returns: { 626, 626 }

  23. 10000

    10000

    999

    999

    Returns: { 1000, 1000 }

  24. 9519

    -1002

    857

    -534

    Returns: { 914, -540 }

  25. 1001

    1001

    -1

    -1

    Returns: { 1000, 1000 }

  26. -2001

    -2001

    1

    1

    Returns: { -666, -666 }

  27. 0

    1

    0

    0

    Returns: { 0, 1 }

  28. 500

    500

    500

    500

    Returns: { 1000, 1000 }

  29. 0

    10000

    0

    0

    Returns: { 0, 1000 }

  30. 10000

    10000

    1000

    1000

    Returns: { }

  31. -1000

    -1000

    -5

    -5

    Returns: { -505, -505 }

  32. 1001

    5001

    -3

    -3

    Returns: { }

  33. 10000

    10000

    1

    999

    Returns: { 2, 1000 }

  34. 0

    5

    0

    0

    Returns: { 0, 5 }

  35. 1

    10

    999

    1000

    Returns: { }

  36. 0

    1000

    0

    500

    Returns: { 0, 1000 }

  37. 2477

    2477

    -1

    -1

    Returns: { 0, 0 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: