__HappY__ @ 2023-07-31 16:40:13
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int w(ll a,ll b,ll 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);
}
const ll N=1e5+5;
ll a[N],b[N],c[N];
int main(){
ll d=0;
for(ll i=1;;i++) {
cin>>a[i]>>b[i]>>c[i];
d++;
if(a[i]==-1&&b[i]==-1&&c[i]==-1) break;
}
for(ll i=1;i<d;i++){
cout<<"w("<<a[i]<<", "<<b[i]<<", "<<c[i]<<") = "<<w(a[i],b[i],c[i])<<endl;
}
return 0;
}
by recollect_i @ 2023-07-31 16:42:06
需要记忆化,这样递归效率低。