Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <list>
- #include <map>
- #include <queue>
- #include <set>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <complex>
- #include <ctime>
- #include <stack>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef vector<int> VI;
- typedef vector< VI > VVI;
- typedef pair<int, int> PII;
- typedef vector<PII> VPII;
- #define REP(i, n) for(int i = 0; i < n; ++i)
- #define RREP(i, n) for(int i = n - 1; i >= 0; --i)
- #define FOR(i, x, y) for(int i = x; i <= y; ++i)
- #define RFOR(i, x, y) for(int i = x; i >= y; --i)
- #define SZ(a) (int)(a).size()
- #define ALL(a) (a).begin(),(a).end()
- #define SORT(a) sort(ALL(a))
- #define CLEAR(x) memset(x, 0, sizeof x);
- #define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
- #define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
- #define pb push_back
- #define sqr(x) (x)*(x)
- #define X first
- #define Y second
- const long double pi=acos(-1.0);
- const long double eps = 1e-9;
- int n;
- int m;
- int k;
- VI a;
- set<pair<int, int> > s[21];
- int main () {
- cin >> n;
- REP (i, n) {
- int t;
- cin >> t;
- a.pb(t);
- REP (j, 21) {
- if ((1<<j) & t) {
- s[j].insert(i, t);
- }
- }
- }
- set<int> ans;
- REP (i, n) {
- ans.insert(a[i]);
- set<pair<int, int> > loc;
- REP (j, 21) {
- set<pair<int, int> >::iterator it = s[j].lower_bound(make_pair(i, (a[i])));
- if (it != s[j].end()) {
- if (*it != make_pair(i, a[i])) {
- loc.insert(make_pair((it->second), j));
- }
- }
- }
- for (set<pair<int, int> >::iterator it = loc.begin(); it != loc.end(); it++) {
- ans.insert(a[i] | (it->first));
- }
- }
- cout << ans.size();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment