标签:line include cout bit com 生日 心情 etc problem
dp[i][j][x][y] 有i个男生j个女生其中任意一段男生最多比女生多x个 女生最多比男生多y个
注意一下边界...有点毒
苟活者在淡红的血色中会依稀看到微茫的希望
#include<bits/stdc++.h>
using namespace std; // 每天好心情从namespace开始
#define mod 12345678
const int maxn = 157;
inline int read() {
int x = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9'){if(c == '-')f = - 1; c = getchar();}
while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar();
return x * f;
}
int dp[maxn][maxn][27][27];
int n,m,k;
int main() {
n = read(),m = read(),k = read();
dp[0][0][0][0] = 1;
for(int i = 0;i <= n;++ i)
for(int j = 0;j <= m;++ j)
for(int l = 0;l <= std::min(i,k);++ l)
for(int e = 0;e <= std::min(j,k);++ e) {
if(i < n && l < k) dp[i + 1][j][l + 1][max(e - 1,0)] += dp[i][j][l][e];
if(j < m && e < k) dp[i][j + 1][max(l - 1,0)][e + 1] += dp[i][j][l][e];
dp[i + 1][j][l + 1][max(e - 1,0)] %= mod;
dp[i][j + 1][max(l - 1,0)][e + 1] %= mod;
}
int ans = 0;
for(int i = 0;i <= k;++ i)
for(int j = 0;j <= k;++ j) ans += dp[n][m][i][j] , ans %= mod;
cout << ans << endl;
return 0;
}
标签:line include cout bit com 生日 心情 etc problem
原文地址:https://www.cnblogs.com/sssy/p/9337802.html