BZOJ1037[ZJOI2008] Birthday party
Test instructions
A row of children sit and play games. The seating scheme satisfies the following conditions: For any successive paragraph, the difference between the number of boys and girls does not exceed K. Given the number of boys, the number of girls and K, the remainder of the number of seating schemes divided by 12345678.
Exercises
DP equation See program, I1i2 said currently selected a few men and a few women, I3i4 said that the current male than the female more than a few and more women than men.
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineInc (I,J,K) for (int i=j;i<=k;i++)5 #defineMoD 123456786 using namespacestd;7 8 intf[ the][ the][ -][ -];9 intMain () {Ten intN,m,k; scanf"%d%d%d",&n,&m,&k); Onef[0][0][0][0]=1; AInc (I1,0, N) Inc (I2,0, M) Inc (i3,0, K) Inc (I4,0, K) { - if(i1!=n&&i3!=k) f[i1+1][i2][i3+1][max (i4-1,0)]= (f[i1+1][i2][i3+1][max (i4-1,0)]+f[i1][i2][i3][i4])%MoD; - if(i2!=m&&i4!=k) f[i1][i2+1][max (i3-1,0)][i4+1]= (f[i1][i2+1][max (i3-1,0)][i4+1]+F[I1][I2][I3][I4])%MoD; the } - intans=0; -Inc (I1,0, K) Inc (I2,0, k) ans= (Ans+f[n][m][i1][i2])%MoD; -printf"%d", ans); +}
20160322
BZOJ1037[ZJOI2008] Birthday party