P2592 [ZJOI2008] birthday party

Title Description

Today is hidadz children's birthday, she invited many friends to her birthday party. hidadz with friends to the garden, sitting in a row going to play the game. In order not to boring game, seated program should meet the following conditions:

For any continuous period, the number of boys and girls does not exceed k.

Soon, children will find a solution and sat down to start the game. hidadz good friend Susie found that such a program is actually a lot of seating, so we quickly found a, then in the end how many do? Love mathematics hidadz and her friends started thinking about the problem ......

Assuming that the men in the party a total of n m a boy and a girl, if you can answer questions and Susie hidadz it? Because this number may be a lot, they just want to know this number is divided by 12345678.

Input and output formats

Input formats:

 

Party.in input file contains only one row of 3 integers, respectively, the number of boys n, the number of girls m, the constant k.

 

Output formats:

 

Party.out output file should contain a line for questions required answers.

——————————————————————————————————————

Is really a more than a malignant tumor

Blur difference, M j I M, the suffix M - M a, M - M b

#include<bits/stdc++.h>
using namespace std;
#define f(a,b) for(int a=0;a<=b;a++)
int n,m,k,f[160][160][22][22]={1},md=12345678,ans=0;
int main()
{
    cin>>n>>m>>k;
    f(i,n)f(j,n)f(a,k)f(b,k)
    if(f[i][j][a][b])
    {    
    f[i+1][j][a+1][max(b-1,0)]=(f[i][j][a][b]+f[i+1][j][a+1][max(b-1,0)])%md;
    f[i][j+1][max(a-1,0)][b+1]=(f[i][j][a][b]+f[i][j+1][max(a-1,0)][b+1])%md;
    }
    f(a,k)f(b,k)
    years = (year + f [n] [m] [a] [b])% m;
    cout << years;
}

 

Guess you like

Origin www.cnblogs.com/SFWR-YOU/p/10927191.html