From c1008fe39217be7f91f0ea23483e747bfbc5743e Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 16 Dec 2019 21:13:07 +0700 Subject: The good, the bad and the ugly --- codechef/plmu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 codechef/plmu.c (limited to 'codechef/plmu.c') 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 + +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; +} -- cgit 1.4.1