diff options
Diffstat (limited to 'codechef/plmu.c')
-rw-r--r-- | codechef/plmu.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/codechef/plmu.c b/codechef/plmu.c new file mode 100644 index 0000000..04c4b0e --- /dev/null +++ b/codechef/plmu.c @@ -0,0 +1,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; +} |