Problem Statement |
| | You are given six integers, minx, maxx, miny, maxy, minz and maxz. Return the number of triplets of integers (x,y,z) that satisfy the following three conditions:
- x is between minx and maxx, inclusive.
- y is between miny and maxy, inclusive.
- z is between minz and maxz, inclusive.
- x * y = z
|
| |
Definition |
| | | Class: | ProductTriplet | | Method: | countTriplets | | Parameters: | int, int, int, int, int, int | | Returns: | long | | Method signature: | long countTriplets(int minx, int maxx, int miny, int maxy, int minz, int maxz) | | (be sure your method is public) |
|
| |
|
| |
Constraints |
| - | maxx will be between 1 and 1,000,000,000, inclusive. |
| - | maxy will be between 1 and 1,000,000,000, inclusive. |
| - | maxz will be between 1 and 1,000,000,000, inclusive. |
| - | minx will be between 1 and maxx, inclusive. |
| - | miny will be between 1 and maxy, inclusive. |
| - | minz will be between 1 and maxz, inclusive. |
| |
Examples |
| 0) | |
| | |
| 1) | |
| | |
| 2) | |
| | | Returns: 4 | | (x,y,z) = (6,5,30), (7,4,28), (7,5,35) and (8,4,32) satisfy all conditions. |
|
|
| 3) | |
| | |
| 4) | |
| | 8176 | 184561 | 1348 | 43168 | 45814517 | 957843164 |
| Returns: 2365846085 | |
|