改了多少我也不知道了,建议自己对照,就我这一脚猫的功夫……
```cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,ansed[21][21][21];
ll w(ll a,ll b,ll c) {
if(a<=0||b<=0||c<=0) return 1;
if(a>20||b>20||c>20){
a=20;b=20;c=20;
}
if(ansed[a][b][c]!=-1) {
return ansed[a][b][c];
}
if(a<b&&b<c) {
ansed[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
return ansed[a][b][c];
}
ansed[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 ansed[a][b][c];
}
int main() {
cin>>a>>b>>c;
memset(ansed,-1,sizeof(ansed));
while(a!=-1||b!=-1||c!=-1) {
ll ans=w(a,b,c);
printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,ans);
cin>>a>>b>>c;
}
return 0;
}
```
~~我还把代码改的偏向自己风格了一点~~
by Huoxiangji @ 2024-08-18 23:16:26