Problem Statement
Let us call an integer x lucky if ends with 777. For example, numbers 2777, 23777, 777 are lucky, but numbers 317, 21377, 7 are not.
Let us call an integer x twisted if ax + b is lucky for some 1 <= a <= A, 0 <= b <= B.
You are given ints X, A and B. Return "YES" if X is twisted, or "NO" if it is not (all quotes for clarity).
Definition
- Class:
- TwistedNumbers
- Method:
- check
- Parameters:
- int, int, int
- Returns:
- String
- Method signature:
- String check(int X, int A, int B)
- (be sure your method is public)
Constraints
- X will be betweeen 1 and 1000, inclusive.
- A will be between 1 and 10, inclusive.
- B will be between 0 and 10, inclusive.
Examples
777
2
1
Returns: "YES"
777 is lucky by itself, so a = 1, b = 0 are OK.776
1
1
Returns: "YES"
1 * 776 + 1 = 777, so 776 is twisted.888
2
2
Returns: "YES"
2 * 888 + 1 = 1777 is lucky.888
2
0
Returns: "NO"
846
10
10
Returns: "YES"
846
10
8
Returns: "NO"
846
7
10
Returns: "NO"