TopCoder problem "NotTwo" used in SRM 452 (Division I Level One , Division II Level Two)



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)
    
3
2
Returns: 4
He can place four stones on the board. Here is one possible arrangement:

- * *
* * -
1)
    
3
3
Returns: 5
* - -
* * -
- * *
2)
    
8
5
Returns: 20

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10561

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13906&pm=10561

Writer:

rng_58

Testers:

PabloGilberto , connect4 , ivan_metelsky

Problem categories:

Math