HDU

/*
  道行太浅了...一开始没看出这是水题
  
  因为如果多组m和k,那么只要输出一组就行了...所以,正确的思路是,想到任何数%2都是1或者0,所以判断输入的所有数据的奇偶个数,如果奇数大于等于偶数个数,就输出 2 1,否则输出 2 0
  
  这次数据有些大,居然忘了cin.tie(0)和cin.sync_with_stdio(false),TLE了一次
*/


#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(false);
	int t, n, ans;
	cin >> t;
	while (t--)
	{
		cin >> n;
		ans = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			if (a[i] % 2) ans++;
		}
		if (ans >= n - ans) cout << "2 1" << endl;
		else cout << "2 0" << endl;		
	} 
	return 0;
}


原文地址:https://www.cnblogs.com/mofushaohua/p/7789531.html