hdu4901The Romantic Hero
来源:互联网 发布:政务大数据平台建设 编辑:程序博客网 时间:2024/06/07 00:47
#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(); }}
0 0
- hdu4901The Romantic Hero
- hdu4901The Romantic Hero dp
- The Romantic Hero
- HDU4901 The Romantic Hero
- hdu4901 The Romantic Hero
- HDU-4901-The Romantic Hero
- hdu 4901 The Romantic Hero
- HDU 4901 The Romantic Hero
- HDOJ 4901 The Romantic Hero
- HDU4901:The Romantic Hero(DP)
- hdu 4901 The Romantic Hero
- hdu 4901 The Romantic Hero
- HDU--4901--The Romantic Hero
- HDU4901-The Romantic Hero(DP)
- HDU 4901 The Romantic Hero
- HDU 4901 The Romantic Hero
- HDU 4901 The Romantic Hero
- hdu 4901 The Romantic Hero
- VC与matlab混编之VC调用matlab程序
- notepad++常见问题解决
- hdu 4907 Tast Schedule
- extjs+MVC架构下的图片显示
- iOS中id与NSObject* 和id<NSObject>的区别
- hdu4901The Romantic Hero
- 马云_拥抱敏捷-----华为的SDN实践
- ZOJ 3795 Grouping 强联通+偏序集
- Ubuntu下单网卡多IP地址的配置
- VC+matlab通过Com接口实现混合编程
- shell 下正则表达式的匹配
- socket image
- poj 3253 Fence Repair(优先队列+哈夫曼树)
- BC-Round3 hdu4907