#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. PHPCMS增加投票选项代码

    <script src="jquery-1.10.1.js"></script> <tr> <th width="20%&quo ...

  2. 算法笔记_108:第四届蓝桥杯软件类省赛真题(JAVA软件开发本科A组)试题解答

     目录 1 世纪末的星期 2 振兴中华 3 梅森素数 4 颠倒的价牌 5 三部排序 6 逆波兰表达式 7 错误票据 8 带分数 9 剪格子 10 大臣的旅费 前言:以下试题解答代码部分仅供参考,若有不 ...

  3. navicat 使用

    sql是操作数据库中数据的语句,在不同的数据库中会略有不同,如mysql,postgreSQL,oracle,sqlserver,sqlite等等,但是sql的基础select.insert.upda ...

  4. SCSS 实用知识汇总

    1.变量声明 $nav-color: #F90; nav { //$width 变量的作用域仅限于{}内 $width: 100px; width: $width; color: $nav-color ...

  5. 【翻译自mos文章】使用dbua升级时,须要手工设置CLUSTER_DATABASE參数么?

    使用dbua升级时,须要手工设置CLUSTER_DATABASE參数么? 来源于: Is Manual Setting Of CLUSTER_DATABASE Parameter Required F ...

  6. 【Linux】别名

    别名就是一种快捷方式,以省去用户输入一长串命令的麻烦. 别名有多种实现方式,可以使用函数,也可以使用alias命令 注意:alias命令的作用只是短暂的.一旦终端关闭,别名则失效,如果要让别名永久生效 ...

  7. 在浏览器中使用JS打开并展示PDF文件

    使用jquery.media.js插件 示例: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=& ...

  8. __str__被print函数调用,目的是打印类的内容到屏幕上

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #__str__被print函数调用,目的是打印类的内容到屏幕上 class APIError(): def ...

  9. Java多线程系列目录(共43篇)(转)

    Java多线程系列目录(共43篇) http://www.cnblogs.com/skywang12345/p/java_threads_category.html

  10. CreateThread、_beginthreadex和AfxBeginThread .

    创建线程好几个函数可以使用,可是它们有什么区别,适用于什么情况呢?参考了一些资料,写得都挺好的,这里做一些摘抄和整合. [参考1]CreateThread, AfxBeginThread,_begin ...