求调

P1464 Function

``` #include<bits/stdc++.h> using namespace std; long long w[100][100][100]; long long s(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 s(20,20,20); } if(w[a][b][c]!=0)return w[a][b][c]; else if(a<b&&b<c) { w[a][b][c]=s(a,b,c-1)+s(a,b-1,c-1)-s(a,b-1,c); return w[a][b][c]; } else { w[a][b][c]=s(a-1,b,c)+s(a-1,b-1,c)+s(a-1,b,c-1)-s(a-1,b-1,c-1); return w[a][b][c]; } } int main() { memset(w,0,sizeof(w)); for(int i=1;;i++) { long long a,b,c; cin>>a>>b>>c; if(a==-1&&b==-1&&c==-1)return 0; printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,s(a,b,c)); } return 0; } ```
by _liujunming_ @ 2024-07-25 14:49:47


|