求调!

P1464 Function

@[Squirrel_GZQ](https://www.luogu.com.cn/user/691330) ```cpp long long g[25][25][25]; ``` ```cpp if(a>25||b>25||c>25) g[a][b][c]= w(20,20,20); ``` 这里会越界
by Qiu101029 @ 2024-05-05 15:34:50


而且还不止这点问题
by Qiu101029 @ 2024-05-05 15:37:12


```cpp #include<bits/stdc++.h> using namespace std; long long g[25][25][25]; bool vis[25][25][25]; //避免所有可能的越界 int w(long long a, long long b, long long c){ if(a<=0||b<=0||c<=0){ return 1;//直接返回1 } else if(a>20||b>20||c>20){ return w(20,20,20);//同理 } else if(vis[a][b][c]==1){ return g[a][b][c]; } else if(a<b&&b<c){ g[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); } else{ g[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); } vis[a][b][c]=1; return g[a][b][c]; } int main(){ long long a,b,c; while(cin>>a>>b>>c){ if(a==-1&&b==-1&&c==-1) return 0; printf("w(%lld, %lld, %lld) = %d\n",a,b,c,w(a,b,c));//%d对应int类型,%lld对应long long类型 } return 0; } ```
by Qiu101029 @ 2024-05-05 15:49:50


@[Qiu101029](/user/1200904) 谢谢谢谢! 这么久终于有人回我了!
by Squirrel_GZQ @ 2024-05-05 21:19:43


@[Qiu101029](/user/1200904) 已关
by Squirrel_GZQ @ 2024-05-05 21:26:38


|