题目链接
题意:给一个数列,任意选择连续的数,问这些数的或(a|b),有几种
#includeusing namespace std; int a[200005]; set s; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { int x = a[i], y = 0; s.insert(x); for (int j = i + 1; j < n; j++) { x |= a[j], y |= a[j]; s.insert(x); if (x == y) //离谱的剪枝 { break; } } } cout << s.size() << endl; return 0; }



