codeforces 1220D

First, the odd and even not hit together.
Then we can take the whole odd, because every time even 1,1 0 0 even, certainly not odd ring.
Consider the case of a legal-take an even number, we can get it all divided by two to become the equivalent of the problem.

#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 2e5+5;
int n;ll a[N];
vector<ll> v;
int ans[70];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;v.resize(n);
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<n;i++){
        ll p = v[i];int cnt=0;
        while (p%2==0)p /= 2, cnt++;
        a[i]=cnt;
        ans[cnt]++;
    }
    int mx = *max_element(ans,ans+70);
    cout<<n-mx<<endl;
    for(int i=0;i<=66;i++){
        if(ans[i]==mx){
            for(int j=0;j<n;j++){
                if(a[j]!=i)cout<<v[j]<<' ';
            }
            return 0;
        }
    }
}

Guess you like

Origin www.cnblogs.com/MXang/p/11618354.html