水题。不过题目很有趣儿。
1 #include <cstdio> 2 3 #define MAXN 100005 4 5 int a[MAXN]; 6 7 int main() { 8 int t, n, m; 9 int i, j, k, tmp, ans; 10 11 scanf("%d", &t); 12 for (k=1; k<=t; ++k) { 13 scanf("%d %d", &n, &m); 14 for (i=0; i<n; ++i) 15 scanf("%d", &a[i]); 16 ans = 0; 17 for (i=0; i<n; ++i) { 18 tmp = 0; 19 for (j=i; j<n; ++j) { 20 tmp |= a[j]; 21 if (tmp < m) 22 ++ans; 23 else 24 break; 25 } 26 } 27 printf("Case #%d: %d\n", k, ans); 28 } 29 30 return 0; 31 }
【HDOJ】4737 A Bit Fun,布布扣,bubuko.com
原文:http://www.cnblogs.com/bombe1013/p/3908726.html