A_little_Jerry @ 2024-02-01 17:36:31
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 21;
vector<vector<vector<int> > > memo(MAX_N, vector<vector<int> >(MAX_N, vector<int>(MAX_N, 0)));
int w(int a, int b, int c) {
if (a <= 0 || b <= 0 || c <= 0)
return 1;
if (a > 20 || b > 20 || c > 20)
return w(20, 20, 20);
if (memo[a][b][c] != 0)
return memo[a][b][c];
int result;
if (a < b && b < c)
result = w(a, b, c-1) + w(a, b-1, c-1) - w(a, b-1, c);
else
result = w(a-1, b, c) + w(a-1, b-1, c) + w(a-1, b, c-1) - w(a-1, b-1, c-1);
memo[a][b][c] = result;
return result;
}
int main() {
int a, b, c;
while (scanf("%d %d %d", &a, &b, &c) == 3) {
if (a == -1 && b == -1 && c == -1)
break;
int result = w(a, b, c);
printf("w(%d, %d, %d) = %d\n", a, b, c, result);
}
return 0;
}
by I_AK_CTSC @ 2024-02-01 17:50:11
@A_little_Jerry where is your long long??
by M3te0rDream @ 2024-02-01 17:54:13
开
by A_little_Jerry @ 2024-02-01 18:28:37
谢谢大佬!已关qwq