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数组里的所 ...
随机推荐
- android 实现QQ好友列表
在某些Android开发群里,看到有些新手问怎么实现QQ好友列表,其实网上一搜挺多的.接触Android,也才一年的时间,大部分时间花在工作上(解bug...),界面上开发很少参与.自己维护的系统应用 ...
- cmd命令之set详解
C:\Users\Administrator>set ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\Administrator\AppData\ ...
- Java从零开始学二十二(集合Set接口)
一.Set接口的定义 Set接口也是Collection接口的子接口,但是与Collection或List接口不同的是,Set接口中不能加入重复的元素 Set接口的主要方法与Collection是一致 ...
- eclipse手动指定启动的jdk版本
在eclipse.ini中添加 -vm D:/wwjDocument/JDK6/jre/bin/client/jvm.dll -vmargs -Dosgi.requiredJavaVersion=1. ...
- TOMCAT配置管理员
迁移时间--2017年7月9日15:16:02Author:Marydon CreateTime--2016年10月18日16:19:22Author:Marydon配置tomcat管理员参考链接 ...
- 如何通过from语句调用模块的变量名?
# -*- coding: utf-8 -*- #python 27 #xiaodeng #如何通过from语句调用模块的变量名? #my.py def printer(x): print x #如何 ...
- Jprofiler监控工具(内存泄漏)
内存泄漏 1.测试代码 /** * JProfiler内存监控例子 * * @author yhye * @2011-11-9上午09:46:06 */ public class JProfilerM ...
- springMVC + hadoop + httpclient 文件上传请求直接写入hdfs
1.首先是一个基于httpclient的java 应用程序,代码在这篇文章的开头:点击打开链接 2.我们首先写一个基于springMVC框架的简单接收请求上传的文件保存本地文件系统的demo,程序代码 ...
- 添加space_key, enter_key, clear_key, delete_key的处理。
final EditText view = (EditText) mInflater.inflate(R.layout.sms_receipient_input, null); view.setOnK ...
- PHP-中文在计算机中的存储
经常我们打开外国网站的时候出现乱码,又或者打开很多非英语的外国网站的时候,显示的都是口口口口口的字符, WordPress程序是用的UTF-8,很多cms用的是GB2312. ● 为什么有这么多编码? ...