TopcoderArchive
TCO7 Sep 2004
TCO04 Wildcard

CubeSum

Problem statement, definition, constraints, and public examples.

Problem Statement

Given an int, N, return the number of ways to represent N as the sum of 4 non-negative perfect cubes. Do not count different permutations of the same 4 cubes more than once. For example, (0,0,0,1) is the same as (1,0,0,0).

Definition

Class:
CubeSum
Method:
count
Parameters:
int
Returns:
int
Method signature:
int count(int N)
(be sure your method is public)

Constraints

  • N will be between 1 and 100,000,000, inclusive.

Examples

  1. 1
    Returns: 1
    Keep in mind that 0 is a perfect cube so 1 can be represented as 0+0+0+1
  2. 4
    Returns: 1
    1+1+1+1 = 4
  3. 2072
    Returns: 4
    0 + 1 + 7*7*7* + 12*12*12 = 0 + 1 + 343 + 1728 = 2072 0 + 7*7*7 + 9*9*9 + 10*10*10 = 0 + 343 + 729 + 1000 = 2072 2*2*2 + 4*4*4 + 10*10*10 + 10*10*10 = 8 + 64 + 1000 + 1000 = 2072 4*4*4 + 4*4*4 + 6*6*6 + 12*12*12 = 64 + 64 + 216 + 1728 = 2072
  4. 456
    Returns: 0
Back to all problems