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