http://acm.hdu.edu.cn/showproblem.php?pid=4737
【题意】:给出a数组和m,求 f(i, j) = ai|ai+1|ai+2| ... | aj ,f(i, j) < m的i j 对数
1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 #define inf 1000000000 7 #define LL __int64 8 9 LL a[100002]; 10 11 int main() 12 { 13 LL cas=1,t,n,m; 14 scanf("%I64d",&t); 15 LL ans; 16 while(t--) 17 { 18 scanf("%I64d%I64d",&n,&m); 19 ans=0; 20 for(LL i=0;i<n;i++) 21 scanf("%I64d",&a[i]); 22 for(LL i=0;i<n;i++) 23 { 24 LL temp=0; 25 for(LL j=i;j<n;j++) 26 { 27 temp|=a[j]; 28 if(temp>=m) 29 { 30 ans+=n-j; 31 break; 32 } 33 34 } 35 } 36 ans=n*(n+1)/2-ans; 37 printf("Case #%I64d: %I64d ",cas++,ans); 38 } 39 return 0; 40 }