# [CTSC2017]吉夫特

$N=lo{g}_{2}\left(ma{x}_{{a}_{i}}\right)$$N= log_2(max_{a_i})$.

$f\left[u\right]\left[v\right]=\sum _{v\in x}\ast dp\left[u\ast {2}^{\frac{N}{2}}+x\right]$$f[u][v] = \sum_{v \in x}*dp[u*2^\frac{N}{2}+x]$.即前一半为$u$$u$,后一半$v$$v$的超集的方案数之和.(超集就是子集的补集).

#include <bits/stdc++.h>
#define LL long long
using namespace std ;
template <class T> void Read ( T &x, char c = getchar(), bool f = 0 ) {
for ( x = 0 ; !isdigit(c) ; c = getchar() ) f |= c == '-' ;
for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
if (f) x = -x ;
}
const int maxn = 220000, Mod = 1000000007 ;
int n, m, S, f[520][520] ;
int main() {
int i, x, u, v, val, ans = 0 ;
m = 1<<9, S = m-1 ;
for ( i = 1 ; i <= n ; i ++ ) {
u = x/m, v = x%m ;
val = 1 ;
for ( x = u^S ; x ; x = (x-1)&(u^S) )
if (f[x|u][v]) (val += f[x|u][v]) %= Mod ;
(val += f[u][v]) %= Mod ;
for ( x = v ; x ; x = (x-1)&v ) (f[u][x] += val) %= Mod ;
(f[u][0] += val) %= Mod ;
}
for ( i = 0 ; i <= S ; i ++ )
(ans += f[i][0]) %= Mod ;
(ans += Mod-n) %= Mod ;
cout << ans << endl ;
return 0 ;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120