求助!!!【听取WA声一片】

P1464 Function

@[chensizhe](/user/874900) 题目中有四种情况,仔细看题
by Chenyufeng040525 @ 2023-05-27 01:30:48


@[Chenyufeng040525](/user/929850) 感谢感谢,最后发现输出还要换行。。。给我整吐了
by chensizhe @ 2023-05-27 11:21:52


现在这个代码没问题了: ``` #include<bits/stdc++.h> using namespace std; long long f[25][25][25]; 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){ 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(){ long long a,b,c; while(1){ cin>>a>>b>>c; if((a==-1)&&(b==-1)&&(c==-1)){ break; } cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<endl; } return 0; } ```
by chensizhe @ 2023-05-27 11:22:43


|