[BZOJ3866] The Romantic Hero "no more brush it on Earth" series, bzoj3866romantic
Reprinted please indicate the source:Http://blog.csdn.net/vmurder/article/details/42612069
In fact, I feel that the original traffic volume is a little less uncomfortable than unauthorized piracy by 233...
In other words, I don't know if it will become a real hero.
Should that happen? Click it first.
Question:
Returns A sequence, and obtains two subsequences A and B,
Make A strictly before B.
Then, the variance or (^) of A is required to be equal to the sum of B and (&).
Question:
Motion gauge.
Pay attention to heavy judgment .. There is nothing to pay attention to. If you don't judge the same sample, you won't go through 233.
Ah. Good afternoon, decadent ~~~ Unhappy ~~~ Is this question a casual question?
Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 1050#define MOD 1000000007using namespace std;int f[N][N],g[N][N],h[N][N],n;int a[N];int main(){//freopen("test.in","r",stdin);int i,j,k,T;for(scanf("%d",&T);T--;){scanf("%d",&n);f[0][0]=1;for(i=1;i<=n;i++){scanf("%d",&a[i]);for(j=0;j<1024;j++)f[i][j]=f[i-1][j],h[i][j]=0;for(j=0;j<1024;j++){f[i][j^a[i]]+=f[i-1][j],f[i][j^a[i]]%=MOD;h[i][j^a[i]]+=f[i-1][j],h[i][j^a[i]]%=MOD;}}memset(g[n+1],0,sizeof(g[n+1]));g[n+1][1023]=1;for(i=n;i;i--){for(j=0;j<1024;j++)g[i][j]=g[i+1][j];for(j=0;j<1024;j++)g[i][j&a[i]]+=g[i+1][j],g[i][j&a[i]]%=MOD;}for(i=1;i<=n;i++)f[i][0]--,g[i][1023]--;long long ans=0;for(i=1;i<n;i++)for(j=0;j<1024;j++)ans+=(long long)h[i][j]*g[i+1][j],ans%=MOD;printf("%lld\n",ans);}return 0;}