Serie A champions:
Set S It consists of a number of intervals [l,r] and 1<=l<=r<=n F (s) that do not intersect the interval asking for N and F (s) There are several possible s sets
Ideas:
DP good question as to why is DP ... I can only say that the fat God taught me--b
Define DP[I][J] means that when N=i and F (s) =j the number of S collection species then it can be obtained by dp[k][j-1] J-1<=k<=i
To be able to understand this transfer
The first thing we need to do is to add a disjoint interval to j-1 J, [k+1,k+1] [k+1,k+2] ... Can all have a common 2^ (i-k)-1 kinds of extraction
1 because not all of this range is not taken
Why not [k+2,...] Because I'm the k+2 that traverses K. The interval that begins is counted when traversing to k=k+1.
And then we're able to take some intervals. These intervals must intersect with the previous ones.
How does it intersect? Just let one end be within K. Therefore, a co-owned 2^ ((i-k) *k) seed extraction
Final draw Dp[i][j] = Sigma (dp[k][j-1] * (2^ (I-K)-1) * (2^ ((i-k) * k))% MoD
Code:
#include <cstdio> #include <cstring> #include <algorithm> #include <vector>using namespace std; #define N 510#define LL __int64#define mod 1000000007LL dp[n][n],f[n*n];int n,m;int Main () { int i,j,k; scanf ("%d%d", &n,&m); for (i=1,f[0]=1;i<n*n;i++) f[i]= (f[i-1]<<1)%mod; for (i=0;i<=n;i++) dp[i][0]=1; for (i=1;i<=n;i++) {for ( j=1;j<=min (m,i); j + +) {for (k=j-1;k<=i;k++) { dp[i][j ]= (dp[i][j]+dp[k][j-1]* (f[i-k]-1)%mod*f[k* (i-k)]%mod)%mod; }}} printf ("%i64d\n", Dp[n][m]); return 0;}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Codeforces 425E Sereja and sets