hdu4901The Romantic Hero
#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的更多相关文章
- HDU 4901 The Romantic Hero
The Romantic Hero Time Limit: 3000MS Memory Limit: 131072KB 64bit IO Format: %I64d & %I64u D ...
- HDU4901 The Romantic Hero 计数DP
2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/30 ...
- HDU 4901 The Romantic Hero (计数DP)
The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E Description There is ...
- HDU 4901 The Romantic Hero(二维dp)
题目大意:给你n个数字,然后分成两份,前边的一份里面的元素进行异或,后面的一份里面的元素进行与.分的时候依照给的先后数序取数,后面的里面的全部的元素的下标一定比前面的大.问你有多上种放元素的方法能够使 ...
- 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 ...
- HDOJ 4901 The Romantic Hero
DP....扫两次合并 The Romantic Hero Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 ...
- The Romantic Hero
Problem Description There is an old country and the king fell in love with a devil. The devil always ...
- 2014多校第四场1005 || HDU 4901 The Romantic Hero (DP)
题目链接 题意 :给你一个数列,让你从中挑选一些数组成集合S,挑另外一些数组成集合T,要求是S中的每一个数在原序列中的下标要小于T中每一个数在原序列中下标.S中所有数按位异或后的值要与T中所有的数按位 ...
- hdu 4901 The Romantic Hero (dp)
题目链接 题意:给一个数组a,从中选择一些元素,构成两个数组s, t,使s数组里的所有元素异或 等于 t数组里的所有元素 位于,求有多少种构成方式.要求s数组里 的所有的元素的下标 小于 t数组里的所 ...
随机推荐
- Carrer Day有感
2013年10月17日 一.永不放弃,痼疾必须自己克服,否则永远有阴影. 二.若长期无法取得进展,应该换一种方式. 大Boss确实有水平,答到点子上且照顾到听众面子,强.很多话掷地有声,发人深省,比如 ...
- 解决org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0
ide jdk 版本换成对应的 如:sonarqube-6.3 --> jdk1.8
- java数组转json
public String toJsonObject(String[] list) { String json="["; for (int i=0;i<list.length ...
- android.intent.action.MAIN, android.intent.category.LAUNCHER
android.intent.action.MAIN决定应用程序最先启动的Activity android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里
- Spring Framework Ecosystem – Introduction to Spring Projects
来自于:http://springtutorials.com/spring-ecosystem/ Hello and Welcome to Spring Tutorials Blog! Is it f ...
- WPF基础学习第一天
格式 1.XAML格式: <Button x:Name="btnClick" Content="按钮" HorizontalAlignment=" ...
- nexus 介绍
http://juvenshun.iteye.com/blog/349534
- 锋利的jQuery(第二版)源码下载地址
书上给的http://cssrain.sinaapp.com无法访问 问作者邮箱要的: 第1版源码:百度云盘下载:http://pan.baidu.com/share/link?shareid=104 ...
- 如何用python轻松破解wifi密码( 源码 )
摘要: 我得说明下这个东西一点都不高端,甚至看起来有点糟糕.而且用的是单线程~,因为过几天要搬家了,于是.. 环境准备 python2.7 凑合的linux 差不多的无线网卡 pywifi模块 弱口令 ...
- 将form表单转化为json数据
参考地址:https://github.com/hongymagic/jQuery.serializeObject