TopcoderArchiveVisit Topcoder
SRM8 Nov 2005
SRM 271

ConvexHull

Problem statement, definition, constraints, and public examples.

Problem Statement

You have a rectangle with corners at (0, 0) and (m, n). You would like to place a convex polygon inside it such that the polygon's vertices are at integer coordinates. The vertices may lie anywhere inside the rectangle or on its boundary.
You are given m and n, the dimensions of the rectangle. Return the maximal number of vertices contained by the convex polygon.

Definition

Class:
ConvexHull
Method:
intHull
Parameters:
int, int
Returns:
int
Method signature:
int intHull(int m, int n)
(be sure your method is public)

Constraints

  • m and n will be between 3 and 200, inclusive.

Examples

  1. 3
    3
    Returns: 8
  2. 3
    50
    Returns: 8
  3. 4
    4
    Returns: 9
  4. 4
    5
    Returns: 10
  5. 50
    200
    Returns: 74
Back to all problems