Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
my template
/* author : masaow g++ : 17.3.20 */ #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define forn(i,a,b) for( i = a ; i < b ; i++ ) #define debug(x) cout << #x << " " << x << " -- " #define I__O ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define ll long long #define p(x) cout << x << "\n" ; #define MOD 100000007 #define pi pair<int,int> #define vi vector <int> #define pb push_back #define vp vector <pair<ll,ll>> #define endl cout << "\n" #define mi map <int,int> #define f1 first #define s1 second #define in insert #define all(x) x.begin(),x.end() using namespace std ; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set ; const int N = 2e5+7; /* time : 10 : 14 date : 22.01.2020 */ // int L,R,mid,target,idx ; int a[N] ; int tests() { int i,j; int n ; cin >> n; set <int> s; forn(i,0,n){ cin >> a[i] ; s.insert(a[i]) ; } forn(i,0,n){ set <int> vec ; vec.insert(a[i]) ; forn(j,0,31) if(s.find(a[i]+(1<<j)) != s.end() && (s.find(a[i]-(1<<j)) != s.end())){ vec.insert(a[i]+(1<<j)), vec.insert(a[i]-(1<<j)) ; cout << vec.size() << '\n' ; for(auto &x : vec) cout << x << ' ' ; return 0 ; } } forn(i,0,n){ set <int> vec ; vec.insert(a[i]) ; forn(j,0,31) if( s.find(a[i]+(1<<j)) != s.end() ){ vec.insert(a[i]+(1<<j)); cout << vec.size() << '\n' ; for(auto &x : vec) cout << x << ' ' ; return 0 ; } else if( s.find(a[i]-(1<<j)) != s.end() ){ vec.insert(a[i]-(1<<j)) ; cout << vec.size() << '\n' ; for(auto &x : vec) cout << x << ' ' ; return 0 ; } } cout << 1 << '\n' << a[0] << '\n' ; return 0 ; } int main(){ I__O ; int cases = 1 ; //cin >> cases; while(cases--) tests(); return 0 ; }
run
|
edit
|
history
|
help
0
DeepaC++
replace_copy-30-Seconds-of-C++
at_multimap_example
SVGAnimated Value
Newspaper
sdfg
Stream11
BinSearch
fgm
Graph Theory On Strings