Give an n number of columns, and take some numbers to form a new series,
If there are some numbers in the new series and K, then this is a good sequence, ask the number of such a series.
Enumerates its values from the 1~n bit from 1~min (l,k) to update the up-to-date state.
Dp[i] The binary of I in each representation and (1~k), 1 means can be taken, 0 means not to be taken.
#include <iostream> #include <cstring> #include <string> #include <cstdio> #include <cmath > #include <algorithm> #include <vector> #include <queue> #include <map> #define INF 0x3f3f3f3f#define EPS 1e-6#define ll long longconst ll Mod=1e9+7;const int maxn= (1<<21); using namespace Std;ll Dp[ma Xn],ans,v;int N,k,l,d,s;int Main () {int icy,i,j,p,next; scanf ("%d", &icy); while (icy--) {scanf ("%d%d%d", &n,&k,&l); D=abs (L-K); L=min (L,K); S= (1<<k)-1; memset (dp,0,sizeof DP); Dp[0]=1; for (i=0;i<n;i++) {for (j=s;j>=0;j--) {v=dp[j]; if (v==0) continue; for (p=1;p<=l;p++) {next= (1<< (p-1)) |j| ( (j<<p) &s);//plus P itself this number and all the rest of the 1 digits plus the number after p are all the cases after the addition of P dp[next]= (dp[next]+v)%mod; } dp[j]+= (V*d%mod);//AnotherOutside this bit can also take the number not within the [1,k] range, multiply up on the line dp[j]%=mod; }} ans=0; for (i=0;i<=s;i++) {if (i& (1<< (k-1))) {Ans+=dp[i]; Ans%=mod; }} cout<<ans<<endl; } return 0;}