#P1464. Function
Function
Description
For a recursive function :
- If or or , return .
- If or or , return .
- If and , return .
- Otherwise, return $w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1)$.
This is a simple recursive function, but implementing it naively may cause issues. When are all , the number of calls becomes very large. You need to find a way to handle this efficiently.
Note: For example, satisfies both condition 1 and condition 2. Evaluate according to the earliest condition listed above. The answer is .
Input Format
Multiple lines of input. Each line contains three integers .
The input ends with .
Output Format
Output multiple lines. Each line should be in the format:
w(a, b, c) = ans
Mind the spaces.
1 1 1
2 2 2
-1 -1 -1
w(1, 1, 1) = 2
w(2, 2, 2) = 4
Hint
Constraints
- Each input number is an integer in .
- The number of input lines excluding , denoted , satisfies .
Translated by ChatGPT 5
京公网安备 11011102002149号