MagicalGirlLevelTwoDivTwo
SRM 514 · 2011-05-25 · by wrong
Problem Statement
Magical Girls are girls who have magical powers. They fight against evil witches to protect the Earth.
You, one of the Magical Girls, are at point (0, 0) of the plane. You find another Magical Girl at (x, y) and she seems to be injured. So you decide to go to point (x, y) to help her.
You can move only by n-knight jump. For a positive integer n, the n-knight jump is 8 types of moves. You can go from (0, 0) to (n, 1), (n, -1), (-n, 1), (-n, -1), (1, n), (-1, n), (1, -n) or (-1, -n) by using n-knight jump once.
You are given a
Constraints
- jumpTypes will contain between 1 and 10 elements, inclusive.
- Each element of jumpTypes will be between 1 and 30, inclusive.
- All elements of jumpTypes will be distinct.
- x and y will each be between -30 and 30, inclusive.
{2}
5
4
Returns: "YES"
(0, 0) -> (2, 1) -> (4, 2) -> (5, 4).
{3}
5
4
Returns: "NO"
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-30
27
Returns: "YES"
{29}
29
0
Returns: "NO"
{1,3,5,7,9,11,13,15,17,19}
29
30
Returns: "NO"
Submissions are judged against all 117 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class MagicalGirlLevelTwoDivTwo with a public method string isReachable(vector<int> jumpTypes, int x, int y) · 117 test cases · 2 s / 256 MB per case