blob: 04c4b0ee040fc34cec20f839a48b88180accc0bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <stdio.h>
int main()
{
char t;
size_t n, tmp, zeros, twos;
scanf("%hhd", &t);
while (t--) {
scanf("%zu", &n);
for (size_t i = zeros = twos = 0; i < n; ++i) {
scanf("%zu", &tmp);
if (!tmp)
zeros++;
else if (tmp == 2)
twos++;
}
printf("%zu\n", zeros * (zeros - 1) + twos * (twos - 1) >> 1);
}
return 0;
}
|