全部WA求助!

P1464 Function

AC代码 ```cpp #include<bits/stdc++.h> using namespace std; long long f[30][30][30]; long long w(long long a,long long b,long long c) { if (a<=0||b<=0||c<=0) return 1; else if (a>20||b>20||c>20) return w(20,20,20); else if (f[a][b][c]>0) return f[a][b][c]; else 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); } int main() { long long a,b,c; while (1) { 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; } ``` w函数内顺序错了,因为: $$这种时候我们就按最上面的条件来算$$
by MvemiY @ 2022-06-30 19:37:31


@[lizhehao2009](/user/727871) 就是递归的时候爆了
by MvemiY @ 2022-06-30 19:38:12


@[Birdly](/user/620253) 感谢您的帮助!
by lizhehao2009 @ 2022-06-30 19:38:36


上一页 |