第一次做感觉无从下手,这个结论也是不好发现
#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 ",x,y) #define pf(x) printf("%d ",x) #define each(x) for(auto it:x) cout<<it<<endl; #define pii pair<int,int> using namespace std; typedef long long ll; const int maxn=2e6+5; const int maxm=2e5+5; const int inf=1e9; ll n,a[maxn],vis[maxn]; vector<int> bit[66]; int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++){ int pp=0; ll x=a[i]; while(x%2==0) { x/=2; pp++; } bit[pp].push_back(i); } int pp=0; for(int i=1;i<64;i++) if(bit[i].size()>bit[pp].size()) pp=i; for(auto it:bit[pp]) vis[it]=1; cout<<n-bit[pp].size()<<endl; for(int i=1;i<=n;i++) if(!vis[i]) cout<<a[i]<<" "; cout<<" "; }