#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int mm=1000000007;
long long a[1010],b[1010][1024],c[1010][1024];
int n;
void in()
{
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
}
void work()
{
memset(b,0,sizeof(b));
for(int i=1;i<n;i++)
{
int j=i-1;
b[i][a[j]]=1;
for(int k=0;k<1024;k++)
{
b[i][k]+=b[j][k];
b[i][k^a[j]]+=b[j][k];
b[i][k]%=mm;
b[i][k^a[j]]%=mm;
}
}
memset(c,0,sizeof(c));
reverse(a,a+n);
for(int i=1;i<n;i++)
{
int j=i-1;
c[i][a[j]]=1;
for(int k=0;k<1024;k++)
{
c[i][k]+=c[j][k];
c[i][k&a[j]]+=c[j][k];
c[i][k]%=mm;
c[i][k&a[j]]%=mm;
}
}
long long ans=0;
for(int i=1;i<n;i++)
{
for(int j=0;j<1024;j++)
{
ans=(ans+(b[i][j]-b[i-1][j]+mm)%mm*c[n-i][j])%mm;
}
}
cout<<ans<<endl;
}
int main()
{
int exp;
cin>>exp;
while(exp--)
{
in();
work();
}
}

hdu4901The Romantic Hero的更多相关文章

  1. HDU 4901 The Romantic Hero

    The Romantic Hero Time Limit: 3000MS   Memory Limit: 131072KB   64bit IO Format: %I64d & %I64u D ...

  2. HDU4901 The Romantic Hero 计数DP

    2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/30 ...

  3. HDU 4901 The Romantic Hero (计数DP)

    The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E Description There is ...

  4. HDU 4901 The Romantic Hero(二维dp)

    题目大意:给你n个数字,然后分成两份,前边的一份里面的元素进行异或,后面的一份里面的元素进行与.分的时候依照给的先后数序取数,后面的里面的全部的元素的下标一定比前面的大.问你有多上种放元素的方法能够使 ...

  5. HDU 4901 The Romantic Hero 题解——S.B.S.

    The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  6. HDOJ 4901 The Romantic Hero

    DP....扫两次合并 The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 ...

  7. The Romantic Hero

    Problem Description There is an old country and the king fell in love with a devil. The devil always ...

  8. 2014多校第四场1005 || HDU 4901 The Romantic Hero (DP)

    题目链接 题意 :给你一个数列,让你从中挑选一些数组成集合S,挑另外一些数组成集合T,要求是S中的每一个数在原序列中的下标要小于T中每一个数在原序列中下标.S中所有数按位异或后的值要与T中所有的数按位 ...

  9. hdu 4901 The Romantic Hero (dp)

    题目链接 题意:给一个数组a,从中选择一些元素,构成两个数组s, t,使s数组里的所有元素异或 等于 t数组里的所有元素 位于,求有多少种构成方式.要求s数组里 的所有的元素的下标 小于 t数组里的所 ...

随机推荐

  1. LINUX下的Mail服务器的搭建

    电子邮件是因特网上最为流行的应用之一.如同邮递员分发投递传统邮件一样,电子邮件也是异步的,也就是说人们是在方便的时候发送和阅读邮件的,无须预先与别人协同.与传统邮件不同的是,电子邮件既迅速,又易于分发 ...

  2. nodejs检查已安装模块

    命令行 npm ls --depth 0

  3. 如何自定义CollectionView中每个元素的大小和间距

    问题: 让每个元素大小变为104 x 104 Step 1: 在你的视图控制器头文件中实现UICollectionViewFlowLayout协议 eg: @interface XXViewContr ...

  4. ASP.NET MVC+Bootstrap 实现短信验证

    短信验证大家都已经非常熟悉了,基本上每天都在接触手机短信的验证码,比方某宝,某东购物.站点注冊,网上银行等等,都要验证我们的手机号码真实性.这样做有什么优点呢. 曾经咱们在做站点的时候.为了提高用户注 ...

  5. Fiddler SessionFlags

    Each Session object in Fiddler contains a collection of string flags, in the Session.oFlags[] collec ...

  6. JavaScript debugger 语句

    实例 开启 debugger ,代码在执行到第三行前终止. var x = 15 * 5; debugger; document.getElementbyId("demo").in ...

  7. spring @Service()中初始化方法

    @Service(value = "xxxServiceImpl" xxxxxxxx) public class XXXSerivceImpl { public void init ...

  8. json(JavaScript Object Natation)学习

    Json必需的包: commons-httpclient-3.1.jar commons-lang-2.4.jar commons-logging-1.1.1.jar json-lib-2.2.3-j ...

  9. ubuntu中设置xampp开机启动

    sudo ln -s /opt/lampp/lampp /etc/init.d/lampp sudo update-rc.d -f lampp defaults

  10. java 泛型 精析

      Created by Marydon on 1.概述 泛型是Java SE 1.5的新特性,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数: 这种参数类型可以用在类.接口和方法的 ...