Cute_Furina @ 2024-10-27 20:20:26
#include<bits/stdc++.h>
using namespace std;
#define int long long
int f[25][25][25], a, b, c;
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(f[a][b][c] != 0) return f[a][b][c];
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);
}
else {
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() {
while(cin >> a >> b >> c) {
if(a == -1 && b == -1 && c == -1) {
return 0;
}
cout << "w(" << a << "," << b << "," << c << ") = " << w(a, b, c) << endl;
}
return 0;
}
by coldfish987 @ 2024-10-28 02:25:58
输出格式错了
","和下个数中间有空格