fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. namespace std {
  6. #ifndef LOCAL
  7. #define cerr \
  8.   if (0) cerr
  9. #endif
  10. } // namespace std
  11.  
  12. int suff[100005];
  13. int a[100005];
  14. bool dd[1 << 20];
  15. int n;
  16.  
  17. int32_t main() {
  18. ios_base::sync_with_stdio(0);
  19. cin.tie(0);
  20. #ifdef LOCAL
  21. #define task "a"
  22. #else
  23. #define task ""
  24. #endif
  25. if (fopen(task ".inp", "r")) {
  26. freopen(task ".inp", "r", stdin);
  27. freopen(task ".out", "w", stdout);
  28. }
  29. cin >> n;
  30. for (int i = 1; i <= n; i++) cin >> a[i];
  31. for (int i = n; i >= 1; i--) suff[i] = suff[i + 1] | a[i];
  32. for (int i = 1; i <= n; i++) {
  33. int curr = 0;
  34. for (int j = i; j <= n; j++) {
  35. curr |= a[j];
  36. dd[curr] = 1;
  37. if ((curr | suff[j + 1]) == curr) {
  38. break;
  39. }
  40. }
  41. }
  42. int ans = 0;
  43. for (int i = 0; i < 1 << 20; i++) ans += dd[i];
  44. cout << ans;
  45. return 0;
  46. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty