...一开始用了三维的...甚至尝试把它搞成二维的...后来发现根本没法转移呀...

既然dalao说这是初中题,那它就算是一道初中题吧...

dp[i][j][k][p]表示当前有i个男生j个女生,男生比女生k个,女生比男生多p个

然后就没有然后了...

 1 #include<cstdio>
 2 #include<queue>
 3 #include<iostream>
 4 #include<cstring>
 5 #define Ha 12345678
 6 using namespace std;
 7 inline int abs(int x){if(x>0) return x;return -x;}
 8 inline int read(){
 9     int ans=0,f=1;char chr=getchar();
10     while(!isdigit(chr)){if(chr=='-') f=-1;chr=getchar();}
11     while(isdigit(chr)){ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
12     return ans*f;
13 }int n,m,K,f[155][155][25][25],ans;
14 int main(){
15 //    freopen("1037.in","r",stdin);
16 //    freopen("1037.out","w",stdout);
17     n=read(),m=read(),K=read();
18     f[0][0][0][0]=1;
19     for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)for(int k=0;k<=K;k++)for(int p=0;p<=K;p++)
20     f[i+1][j][k+1][max(p-1,0)]=(f[i+1][j][k+1][max(p-1,0)]+f[i][j][k][p])%Ha,f[i][j+1][max(k-1,0)][p+1]=(f[i][j+1][max(k-1,0)][p+1]+f[i][j][k][p])%Ha;
21     for(int i=0;i<=K;i++)for(int j=0;j<=K;j++)
22         ans=(ans+f[n][m][i][j])%Ha;
23     return cout<<ans,0;
24 }