Problem Statement |
| Bob has a width x height rectangular board divided into 1 x 1 cells. Rows of the board are numbered 0 to height-1 and columns are numbered 0 to width-1.
Each cell can contain at most one stone, and the Euclidean distance between each pair of stones must not equal 2. The Euclidean distance between cell in row x1, column y1 and cell in row x2, column y2 is defined as the square root from (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2).
Return the maximal number of stones he can place on the board.
|
|
Definition |
| Class: | NotTwo | Method: | maxStones | Parameters: | int, int | Returns: | int | Method signature: | int maxStones(int width, int height) | (be sure your method is public) |
|
|
|
|
Constraints |
- | width will be between 1 and 1000, inclusive. |
- | height will be between 1 and 1000, inclusive. |
|
Examples |
0) | |
| | Returns: 4 | He can place four stones on the board. Here is one possible arrangement:
- * *
* * -
|
|
|
1) | |
| |
2) | |
| |