Dp
Orz Iwtwiioi
This problem is actually DP ... The original statistical scheme number can be done with dynamic programming Ah = = Use some variables to maintain some information to ensure the feasibility/legitimacy of the scheme
Being too weak is a little sad.
1 /**************************************************************2 problem:10373 User:tunix4 language:c++5 result:accepted6 time:460 Ms7 memory:42660 KB8 ****************************************************************/9 Ten //Bzoj 1037 One#include <vector> A#include <cstdio> -#include <cstring> -#include <cstdlib> the#include <iostream> -#include <algorithm> - #defineRep (i,n) for (int i=0;i<n;++i) - #defineF (i,j,n) for (int i=j;i<=n;++i) + #defineD (i,j,n) for (int i=j;i>=n;--i) - #definePB Push_back + using namespacestd; AInlineintGetint () { at intv=0, sign=1;CharCh=GetChar (); - while(ch<'0'|| Ch>'9'){if(ch=='-') sign=-1; Ch=GetChar ();} - while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} - returnv*Sign ; - } - Const intn=155, inf=~0u>>2, mod=12345678; intypedefLong LongLL; - /******************tamplate*********************/ to intn,m,k,f[n][n][ +][ +],ans; + intMain () { - #ifndef Online_judge theFreopen ("1037.in","R", stdin); *Freopen ("1037.out","W", stdout); $ #endifPanax NotoginsengN=getint (); M=getint (); k=getint (); -f[0][0][0][0]=1; theF (I,0, N) F (J,0, m) F (K1,0, k) F (K2,0, K) { + if(k1+1<=K) (f[i+1][j][k1+1][max (k2-1,0)]+=F[I][J][K1][K2])%=MOD; A if(k2+1<=K) (f[i][j+1][max (k1-1,0)][k2+1]+=F[I][J][K1][K2])%=MOD; the } +F (x,0, k) F (Y,0, k) (Ans+=f[n][m][x][y])%=MOD; -printf"%d\n", ans); $ return 0; $}
View Code
"Bzoj" "1037" "ZJOI2008" birthday party