其他分享
首页 > 其他分享> > Codeforces 1220D 思维 数学 二分图基础

Codeforces 1220D 思维 数学 二分图基础

作者:互联网

原题链接

题意


思路


AC代码

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 200000;

int n;
long long bb[N + 5];
int col[N + 5] = {0};
vector<int> q2[105];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lld", &bb[i]);
	}
	int mx = 0, mi = 0;
	for (int i = 1; i <= n; ++i)
	{
		long long p = bb[i];
		while (p % 2 == 0)
		{
			++col[i];
			p /= 2;
		}
		q2[col[i]].push_back(i);
	}
	for (int i = 0; i <= 64; ++i)
	{
		if (q2[i].size() > mx)
		{
			mx = q2[i].size();
			mi = i;
		}
	}
	printf("%d\n", n - mx);
	for (int i = 1; i <= n; ++i)
	{
		if (col[i] != mi)
		{
			printf("%lld ", bb[i]);
		}
	}
	return 0;
}

标签:二分,奇数,1220D,Codeforces,偶数,int,奇环,include,集合
来源: https://www.cnblogs.com/int-me-X/p/14355947.html