chenshixue @ 2023-12-23 14:21:54
#include<bits/stdc++.h>
using namespace std;
int w(int a,int b,int 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(a<b&&b<c){
return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
}
else{
return 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(){
int a,b,c;
while(cin>>a>>b>>c){
if(a==-1&&b==-1&&c==-1){
break;
}
else cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<endl;
}
return 0;
}
帮个忙求求了
by _chicken_ @ 2023-12-23 14:33:56
不开long long见祖宗
by _chicken_ @ 2023-12-23 14:34:21
TLE建议记忆化搜索