JCZ_William @ 2024-09-07 17:14:44
求调
#include <iostream>
using namespace std;
long long a, b, c, f[25][25][25];
long long w(int a, int b, int c)
{
if (a <= 0 or b <= 0 or c <= 0)
{
return 1;
}
else if (a > 20 or b > 20 or c > 20)
{
return w(20 , 20 , 20);
}
else if (f[a][b][c])
{
return f[a][b][c];
}
else if (a < b and b < c)
{
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];
}
else
{
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()
{
while (true)
{
cin >> a >> b >> c;
if (a == -1 and b == -1 and c == -1)
{
break;
}
cout << "w(" << a << ", " << b << ", " << c << ") = " << w(a , b , c) << endl;
}
return 0;
}