xawmh2023 @ 2023-12-31 15:39:26
#include <iostream>
using namespace std;
const int N = 23;
int f[N][N][N];
int w(long long a,long long b,long long c)
{
if (f[a][b][c])
{
return f[a][b][c];
}
if (a <= 0 || b <= 0 || c <= 0)
{
f[1][1][1] = 1;
return 1;
}
if (a > 20 || b > 20 || c > 20)
{
f[20][20][20] = w(20,20,20);
return f[20][20][20];
}
if (a < b && b < c)
{
f[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
}
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);
return f[a][b][c];
}
int main()
{
long long a,b,c;
while(true)
{
cin >> a >> b >> c;
if(a == -1 && b == -1 && c == -1)
break;
cout << "w(" << a << ", " << b << ", " << c << ") = ";
cout << w(a, b, c) << endl;
}
return 0;
}
自我感觉良好
by xawmh2023 @ 2023-12-31 16:01:19
记得@我一下
by Elysian_Realme @ 2023-12-31 16:31:09
@xawmh2023 13行为什么要赋给f[1][1][1]???
by Elysian_Realme @ 2023-12-31 16:31:42
它也不等于1啊 @xawmh2023
by xawmh2023 @ 2023-12-31 16:47:57
刚刚找到这个错误,谢谢大佬!!! 问了一下老师,才发现漏洞百出,再次感谢您!!!
by xawmh2023 @ 2023-12-31 16:48:20
也祝您新年快乐