Problem Statement |
| A quadruplet of non-negative integers (a,b,c,d) is called a divisor quadruplet if there exists at least one positive integer N that satisfies the following four conditions:
- N has exactly a divisors x such that x ≡ 0 (mod 4).
- N has exactly b divisors x such that x ≡ 1 (mod 4).
- N has exactly c divisors x such that x ≡ 2 (mod 4).
- N has exactly d divisors x such that x ≡ 3 (mod 4).
You are given long[]s A, B, C and D. Return the number of divisor quadruplets (a,b,c,d) such that A contains a, B contains b, C contains c and D contains d. |
|
Definition |
| Class: | ModuloFourDivisor | Method: | countQuadruplets | Parameters: | long[], long[], long[], long[] | Returns: | int | Method signature: | int countQuadruplets(long[] A, long[] B, long[] C, long[] D) | (be sure your method is public) |
|
|
|
|
Notes |
- | x ≡ k (mod 4) means (x - k) is divisible by 4. |
|
Constraints |
- | A, B, C and D will contain between 1 and 50 integers, inclusive. |
- | Each element of A, B, C and D will be between 0 and 1,000,000,000,000,000,000 (10^18), inclusive. |
- | A, B, C and D will contain no duplicate elements. |
|
Examples |
0) | |
| | Returns: 1 | (1, 1, 1, 0) is a divisor quadruplet because N = 4 satisfies the conditions. |
|
|
1) | |
| | Returns: 0 | All integers have at least one divisor. |
|
|
2) | |
| | Returns: 1 | (0, 0, 0, 0) is not a divisor quadruplet. (0, 1, 0, 0) is a divisor quadruplet. |
|
|