BZOJ1037[ZJOI2008] Birthday party

Source: Internet
Author: User

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

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.