#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue> #include<cmath> #include<map> #include<stack> #include<set> #include<bitset> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; #define pb(x) push_back(x) #define cls(x, val) memset(x, val, sizeof(x)) #define fi first #define se second #define mp(x, y) make_pair(x, y) #define inc(i, l, r) for(int i=l; i<=r; i++) const int inf = 0x3f3f3f3f; const int maxn = 20; int l1, l2, l3, d; const int mod = 11380; int dp[maxn][maxn][maxn][40]; int dfs(int a, int b, int c, int depth){ if((dp[a][b][c][depth])>=0) return dp[a][b][c][depth]; if(a+b+c == 0) return dp[a][b][c][depth] = 1; if(depth == 0) return dp[a][b][c][depth] = 0; int ans = 0; for(int i=0; i<=c; i++){ if(i) ans += dfs(0, 0, i-1, depth-1)*dfs(a, b, c-i, depth)%mod, ans%=mod; for(int j=0; j<=b; j++){ if(j) ans += dfs(0, j-1, i, depth-1)*dfs(a, b-j, c-i, depth)%mod, ans%=mod; for(int k=1; k<=a; k++){ ans += dfs(k-1, j, i, depth-1)*dfs(a-k, b-j, c-i, depth)%mod; ans %= mod; } } } return dp[a][b][c][depth] = ans; } int main(){ while(~scanf("%d%d%d%d", &l1, &l2, &l3, &d)){ cls(dp, -1); int ans1 = dfs(l1, l2, l3, d); if(d!=0) dfs(l1, l2, l3, d-1); int ans2; if(d == 0) ans2 = 0; else ans2 = dp[l1][l2][l3][d-1]; printf("%d\n", ((ans1-ans2)%mod+mod)%mod); } }
|