TopcoderArchive
TCO11 Apr 2010
TCO10 Final

EnclosingSquare

Problem statement, definition, constraints, and public examples.

Problem Statement

Find the area of the minimum square in the plane, such that its 4 vertices are distinct lattice points and there are exactly n lattice points strictly inside it. If there is no such square, return 0 instead.

Definition

Class:
EnclosingSquare
Method:
getMinimum
Parameters:
long
Returns:
long
Method signature:
long getMinimum(long n)
(be sure your method is public)

Notes

  • A lattice point in the coordinate plane is a point whose x-coordinate and y-coordinate are both integers.

Constraints

  • n will be between 0 and 1,000,000,000,000, inclusive.

Examples

  1. 4
    Returns: 5
    The square below contains exactly 4 lattice points strictly inside itself and has an area of 5.
  2. 3
    Returns: 0
    There is no such square.
  3. 1000000000000
    Returns: 1000000000001
  4. 101
    Returns: 104
  5. 85
    Returns: 90
Back to all problems