提交时间:2025-02-10 12:39:48
运行 ID: 36199
#include <bits/stdc++.h> #define int long long using namespace std; int n; int s[100005]; unordered_set<int> S; int x,y; signed main(){ freopen("set.in","r",stdin); freopen("set.out","w",stdout); scanf("%lld",&n); for (int i=1;i<=n;i++){ scanf("%lld",&s[i]); S.emplace(s[i]); } while (1){ int lsize=S.size(); for (auto i:S){ for (auto j:S){ if (i<=j){ x=i; y=j; if (x!=(x&y)){ S.insert(x&y); } if (y!=(x|y)){ S.insert(x|y); } } } } if (S.size()==lsize){ break; } } cout<<S.size()<<endl; return 0; }