BigFunc
SRM 132 · 2003-02-01 · by brett1479
SRM 132 · 2003-02-01 · by brett1479
Problem Statement
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.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
0)
10 1 Returns: 1
1)
1 4 Returns: 10
2)
10 10 Returns: 14914341925
3)
20 8 Returns: 1236466399775623332
4)
50 2 Returns: 1125899906842625
Submissions are judged against all 122 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class BigFunc with a public method long long value(int m, int n) · 122 test cases · 2 s / 256 MB per case