#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. jquery文字填写自动高度

    下面开始写一个jquery插件 (function($){ $.fn.autoTextarea = function(options) { var defaults={ maxHeight:null, ...

  2. 【Nodejs】理想论坛帖子爬虫1.01

    用Nodejs把Python实现过的理想论坛爬虫又实现了一遍,但是怎么判断所有回调函数都结束没有好办法,目前的spiderCount==spiderFinished判断法在多页情况下还是会提前中止. ...

  3. 连接SDE空间数据库——SQL Server篇

    一.软件配置 要从 ArcMap 连接至 SQL Server 中的数据库或地理数据库,请在 ArcMap 计算机上安装 SQL Server native client 或 Microsoft OD ...

  4. JavaScript 之 截取字符串函数

    一.函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组 例子: str=”jpg|bmp|gif|ico|png”; arr=theString.split(”|”); //a ...

  5. ORACLE常用监控语句(未完待续)

    --查询日志的切换频率 select  t1.RECID as srecid        ,t2.RECID as erecid        ,t1.FIRST_TIME as stime     ...

  6. 腾讯云兑现存储获取临时授权C#版

    腾讯官方没有提供C#版的,没办法自己根据java版改写了一个,这里面的坑花了我20多个小时,所以记录下 <%@ WebHandler Language="C#" Class= ...

  7. Modifying a Request or Response

    To make custom changes to web requests and responses, use FiddlerScript to add rules to Fiddler's On ...

  8. 关于zookeeper的自我解惑

    分布式服务框架 Zookeeper -- 管理分布式环境中的数据: http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/  ...

  9. dos下遍历目录和文件的代码(主要利用for命令)(转)

    ===== 文件夹结构 ============================================= D:\test ---A Folder 1 |-----A file 1.txt | ...

  10. 恭喜您成为2014年度Microsoft MVP!