PROGRAMMING:Weight function
Title Description
For a recursive function w (a, B, c) w (a, B, c)
• If a ≤ 0 or B ≤ 0 or C ≤ 0, the return value is 1
• If a > 20 or b > 20 or C > 20, return w (20,20,20)
• If a < B and B < C, return w (a, B, C − 1) + W (a, B − 1, C − 1) − w (a, B − 1, c)
• Other cases 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 there may be some problems in its implementation. When a, B and C are all 15, the number of calls will be very large. You have to think of a way
For example, w (30, − 1,0) satisfies both condition 1 and condition 2. In this case, we calculate according to the top condition, so the answer is 1
###Input format:
There will be several lines.
And it ends with − 1, − 1, − 1.
Ensure that the input number is between [- 9223372036854758089223372036854775807] and is an integer.
###Output format:
Output several lines, each line format:
W (a, B, c) = ans / / note the space..
###Input example:
Here is a set of inputs. For example:
```in
1 1 1
2 2 2
-1 -1 -1
```
###Output example:
The corresponding output is given here. For example:
```out
w(1, 1, 1) = 2
w(2, 2, 2) = 4
```
answer:If there is no answer, please comment
For a recursive function w (a, B, c) w (a, B, c)
• If a ≤ 0 or B ≤ 0 or C ≤ 0, the return value is 1
• If a > 20 or b > 20 or C > 20, return w (20,20,20)
• If a < B and B < C, return w (a, B, C − 1) + W (a, B − 1, C − 1) − w (a, B − 1, c)
• Other cases 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 there may be some problems in its implementation. When a, B and C are all 15, the number of calls will be very large. You have to think of a way
For example, w (30, − 1,0) satisfies both condition 1 and condition 2. In this case, we calculate according to the top condition, so the answer is 1
###Input format:
There will be several lines.
And it ends with − 1, − 1, − 1.
Ensure that the input number is between [- 9223372036854758089223372036854775807] and is an integer.
###Output format:
Output several lines, each line format:
W (a, B, c) = ans / / note the space..
###Input example:
Here is a set of inputs. For example:
```in
1 1 1
2 2 2
-1 -1 -1
```
###Output example:
The corresponding output is given here. For example:
```out
w(1, 1, 1) = 2
w(2, 2, 2) = 4
```
answer:If there is no answer, please comment