AcWing 5398. 数组分割——java
原题链接
简单
作者:
大猩猩吃月亮
,
2025-04-09 18:03:48
· 河北
,
所有人可见
,
阅读 2
import java.util.*;
import java.io.*;
public class Main {
static int MOD = 1000000007;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-- > 0) {
int n = Integer.parseInt(br.readLine());
String[] s = br.readLine().split(" ");
int[] a = new int[n];
long sum = 0;
int even = 0, odd = 0;
for(int i = 0; i < n; i++) {
a[i] = Integer.parseInt(s[i]);
if(a[i] % 2 != 0) odd++;
else even++;
}
if(odd % 2 != 0) System.out.println("0");
else {
if(odd == 0) odd = 1;
int res = 1;
for(int i = 0; i < even + odd - 1; i++) {
res = res * 2 % MOD;
}
System.out.println(res);
}
}
}
}