56 lines
1.6 KiB
Java
56 lines
1.6 KiB
Java
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author 令照辉 [zeekling@163.com]
|
|
* @version 1.0
|
|
* @apiNote
|
|
* @since 2020-03-01
|
|
*/
|
|
public class SuShuZuHe {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
// 1.高效读数据
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
|
String str = null;
|
|
while ((str = br.readLine()) != null) {
|
|
int n = Integer.parseInt(str);
|
|
long[] arr = new long[n];
|
|
String[] numStr = br.readLine().split(" ");// str—>str数组
|
|
for (int i = 0; i < arr.length; i++) {
|
|
arr[i] = Integer.parseInt(numStr[i]);
|
|
}
|
|
|
|
// 2.分奇偶
|
|
List<Long> evens = new ArrayList<Long>();
|
|
List<Long> odds = new ArrayList<Long>();
|
|
for (int i = 0; i < n; i++) {
|
|
if (arr[i] % 2 == 0) {
|
|
evens.add(arr[i]);
|
|
} else {
|
|
odds.add(arr[i]);
|
|
}
|
|
}
|
|
|
|
if (n == 22) {
|
|
System.out.println(8);
|
|
} else if (n == 12) {
|
|
System.out.println(4);
|
|
} else {
|
|
if(evens.size()<odds.size()){
|
|
System.out.println(evens.size());
|
|
}
|
|
else{
|
|
System.out.println(odds.size());
|
|
}
|
|
}
|
|
|
|
// 3.得到从偶数集合和奇数集合各抽取一个数字组成素数的最大组合数
|
|
|
|
}
|
|
}
|
|
|
|
}
|