#include <bits/stdc++.h>
#define Mo 1000000007
#define MAXN 50
#define MAXK 10
using namespace std;
int dp[*MAXN+][<<MAXK];
class AlienAndSetDiv2 {
public:
int N, K;
int calc(int n, int unmatched)
{
int res = ;
if (- != dp[n][unmatched]) {
return dp[n][unmatched];
} if (n == * N + ) {
if ( == unmatched) {
res = ;
}
} else {
if ( == unmatched) {
res += ( * calc(n + , ) ) % Mo;
} else {
int newset = unmatched;
int i = ;
for (i = ; (newset & 0x80000000 ) == ; newset = ( newset << ), ++i) {
}
int mx = - i;
res += calc(n + , (unmatched - ( << mx)) << );
res %= Mo; if (mx != K - ) {
newset = unmatched;
newset = ( (newset << ) | );
res += calc(n + , newset);
res %= Mo;
}
}
}
dp[n][unmatched] = res;
return res;
}
05-10 22:56