TopcoderArchiveVisit Topcoder
SRM1 Feb 2003
SRM 132

BigFunc

Problem statement, definition, constraints, and public examples.

Problem Statement

Your math teacher has given you the following mystery functions:
           {            n                  if m = 0
f(m,n) =   {            0                  if n = 0
           { n*f(m-1,n) - g(m-1,n-1)	   otherwise

           {        0                 if y = 0
g(x,y) =   {  
           { f(x,y) + g(x,y-1)        otherwise
Given m and n your function will return the value of f.

Definition

Class:
BigFunc
Method:
value
Parameters:
int, int
Returns:
long
Method signature:
long value(int m, int n)
(be sure your method is public)

Notes

  • It should be clear from the above recurrences that the function will always converge to a value. i.e. it will not go into an infinite recurrence.

Constraints

  • m will be between 0 and 100 inclusive
  • n will be between 0 and 100 inclusive
  • The return value will be between 0 and 2^63-1 inclusive.

Examples

  1. 10
    1
    Returns: 1
  2. 1
    4
    Returns: 10
  3. 10
    10
    Returns: 14914341925
  4. 20
    8
    Returns: 1236466399775623332
Back to all problems