link:http://acm.hdu.edu.cn/showproblem.php?pid=4737
暴力可以过啊。O(N^2)的复杂度。
#include <cstdio> ]; int main(void) { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif int t; scanf("%d", &t); long long int ans; ; i <= t; ++i) { ans = ; printf("Case #%d: ", i); int m; int n, j, k; scanf("%d%d", &n, &m); ; j < n; scanf("%d", a+j++)); int tmp; ; j < n; ++j) { tmp = a[j]; for (k = j; k < n; ++k) { tmp = tmp | a[k]; if (tmp < m) ans++; else break; } } printf("%lld\n", ans); } ; }
数据出的不好吧==
比如100000个1怎么破?