TopcoderArchiveVisit Topcoder
SRM12 Nov 2009
SRM 467

ShorterSuperSum

Problem statement, definition, constraints, and public examples.

Problem Statement

SuperSum is a function defined as:
  • SuperSum(0 , n) = n, for all positive n.
  • SuperSum(k , n) = SuperSum(k-1 , 1) + SuperSum(k-1 , 2) + ... + SuperSum(k-1 , n), for all positive k, n.

Given k and n, return the value for SuperSum(k , n).

Definition

Class:
ShorterSuperSum
Method:
calculate
Parameters:
int, int
Returns:
int
Method signature:
int calculate(int k, int n)
(be sure your method is public)

Constraints

  • k will be between 1 and 14, inclusive.
  • n will be between 1 and 14, inclusive.

Examples

  1. 1
    3
    Returns: 6
    When k = 1, SuperSum is equal to the sum of the first n = 3 numbers: 1 + 2 + 3 = 6.
  2. 2
    3
    Returns: 10
    SuperSum(2 , 3) = SuperSum(1 , 1) + SuperSum(1 , 2) + SuperSum(1 , 3) = 1 + 3 + 6 = 10.
  3. 4
    10
    Returns: 2002
  4. 10
    10
    Returns: 167960
Back to all problems