24KB24 @ 2022-02-03 15:44:17
#include <iostream>
using namespace std;
int f[25][25][25];
int fun(int a, int b, int c) {
if (a <= 0 || b <= 0 || c <= 0)
return 1;
else if (a > 20 || b > 20 || c > 20)
return fun(20, 20, 20);
else if (f[a][b][c] != 0)
return f[a][b][c];
else if (a < b && b < c)
f[a][b][c] = fun(a, b, c - 1) + fun(a, b - 1, c - 1) - fun(a, b - 1, c);
else
f[a][b][c] = fun(a - 1, b, c) + fun(a - 1, b - 1, c) + fun(a - 1, b, c - 1) - fun(a - 1, b - 1, c - 1);
return f[a][b][c];
}
int main() {
while (1) {
int a, b, c;
cin >> a >> b >> c;
if (a == -1 && b == -1 && c == -1)
break;
cout << "fun(" << a << ", " << b << ", " << c << ") = " << fun(a, b, c) << endl;
}
}
by 蘸醋的三文鱼 @ 2022-02-03 15:51:10
然而输出的函数名打错了
by 24KB24 @ 2022-02-03 16:47:39
@蘸醋的三文鱼 哈哈哈哈哈哈哈,脑子抽了,,谢谢