20pts
查看原帖
20pts
751572
Jason_LiDongJin楼主2023/2/21 16:41

错在哪……


#include <bits/stdc++.h>
#define int long long
using namespace std;
int f[25][25][25];

int w(int a, int b, int c) {
	if (a <= 100 && b <= 100 && c <= 100 && f[a][b][c])
		return f[a][b][c];
	if (a <= 0 || b <= 0 || c <= 0)
		return 1;
	if (a > 20 || b > 20 || c > 20)
		return f[a][b][c] = w(20, 20, 20);
	if (a < b && b < c)
		return f[a][b][c] = (w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c));
	return f[a][b][c] = w(a - 1, b, c) + w(a - 1, b - 1, c) + w(a - 1, b, c - 1) - w(a - 1, b - 1, c - 1);
}

signed main() {
	int x, y, z;
	while (cin >> x >> y >> z) {
		if (x == -1 && y == -1 && z == -1)
			break;
		cout << "w(" << x << ", " << y << ", " << z << ") = " << w(x, y, z) << "\n";
	}
	return 0;
}
2023/2/21 16:41
加载中...