标签:binary arch namespace mic const c++ cpp alt 超过
集合的大小不会超过三
#include<bits/stdc++.h> #define forn(i, n) for (int i = 0 ; i < int(n) ; i++) #define fore(i, s, t) for (int i = s ; i < (int)t ; i++) #define fi first #define se second #define all(x) x.begin(),x.end() #define pf2(x,y) printf("%d %d\n",x,y) #define pf(x) printf("%d\n",x) #define each(x) for(auto it:x) cout<<it<<endl; #define pii pair<int,int> #define sc(x) scanf("%d",&x) using namespace std; typedef long long ll; const int maxn=2e5+5; const int maxm=2e5+5; const int inf=1e9; int main(){ int n; cin>>n; vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i]; sort(all(a)); vector<int> ans = {a[0]}; for(int i=0;i<n;i++){ for(int j=0;j<31;j++){ int lx=a[i]-(1<<j); int rx=a[i]+(1<<j); bool isl=binary_search(all(a),lx); bool isr=binary_search(all(a),rx); if(isl && isr && ans.size()<3) { ans={lx,a[i],rx}; } if(isl && ans.size()<2) ans={lx,a[i]}; if(isr && ans.size()<2) ans={a[i],rx}; } } cout<<ans.size()<<endl; for(auto it:ans) cout<<it<<‘ ‘; cout<<endl; }
标签:binary arch namespace mic const c++ cpp alt 超过
原文地址:https://www.cnblogs.com/033000-/p/12397460.html