Data range =>o (N4) DP
#include <cstdio> #include <cstring> #include <algorithm> #include <cctype>using namespace std; #define REP (I,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) #define CLR (x,c) memset (X,c, sizeof (x)) int Dp[305][155][25][25];const int Mod=12345678;int main () { int n,m,s;scanf ("%d%d%d", &n,&m, &s); Dp[0][0][0][0]=1; Rep (I,0,n+m-1) Rep (J,0,n) Rep (k,0,s) Rep (t,0,s) if (Dp[i][j][k][t]) { if (i-j<m&&t<s) Dp[i+1][j][max (k-1,0)] [T+1]= (Dp[i+1][j][max (k-1,0)][t+1]+dp[i][j][k][t])%mod; if (j<n&&k<s) Dp[i+1][j+1][k+1][max (t-1,0)]= (Dp[i+1][j+1][k+1][max (t-1,0)]+dp[i][j][k][t])%mod; } int ans=0; Rep (i,0,s) Rep (j,0,s) ans= (ans+dp[n+m][n][i][j])%mod; printf ("%d\n", ans); return 0;}
1037: [ZJOI2008] Birthday party time limit:10 Sec Memory limit:162 MB
submit:2141 solved:1271
[Submit] [Status] [Discuss] Description
Today is Hidadz children's birthday, she invited a lot of friends to attend her birthday party. Hidadz with his friends in the garden, intending to
Sit in a row and play the game. For the game to not be bored, the solution should meet the following conditions: For any successive paragraph, the number of boys and girls
The difference does not exceed K. Soon, the children found a way to sit down and start the game. Hidadz's good friend Susie found that such a seating plan actually
is a lot of, so we quickly found a kind, then how many kinds of it? Hidadz and her friends began to think about the problem.
...... If there are N boys and M girls in the party, can you answer the questions of Susie and Hidadz? As this number may be very
More, they just want to know the remainder of this number divided by 12345678.
Input
Contains only a total of 3 integers, the number of boys N, the number of girls m, and the constant K.
Output
Should contain one row for the answer asked in the question.
Sample Input1 2 1Sample Output1HINT
N, m≤150,k≤20.
Source [Submit] [Status] [Discuss]
bzoj1037: [ZJOI2008] Birthday party