求助!

P1464 Function

@[13833925596mm](/user/486441) ```cpp #include <bits/stdc++.h> using namespace std; long long k[21][21][21]={0}; long long f(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 f(20,20,20); else if(k[a][b][c]!=0) return k[a][b][c]; else if(a<b && b<c){ k[a][b][c]=f(a,b,c-1)-f(a,b-1,c)+f(a,b-1,c-1); return k[a][b][c]; } else k[a][b][c]=f(a-1,b,c)-f(a-1,b-1,c-1)+f(a-1,b-1,c)+f(a-1,b,c-1); return k[a][b][c]; } int main(){ long long a,b,c; cin>>a>>b>>c; while(a!=-1 || b!=-1 || c!=-1){ memset(k,0,sizeof(k)); cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f(a,b,c)<<endl; cin>>a>>b>>c; } return 0; } ``` 自行找不同
by _Andy_Lin_ @ 2022-07-15 16:22:11


@[Andy_Lin](/user/261370) 谢谢!
by 13833925596mm @ 2022-07-15 16:33:40


|