"Bzoj" "1037" "ZJOI2008" birthday party

Source: Internet
Author: User

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&LT;=K) (f[i+1][j][k1+1][max (k2-1,0)]+=F[I][J][K1][K2])%=MOD; A         if(k2+1&LT;=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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.