From 4c5ed94087a691ce47882786aea64f7b5bf3c130 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sat, 20 Oct 2018 11:27:47 +0700 Subject: Bon appétit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codechef/teammate.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 codechef/teammate.py (limited to 'codechef/teammate.py') diff --git a/codechef/teammate.py b/codechef/teammate.py new file mode 100644 index 0000000..cc3846e --- /dev/null +++ b/codechef/teammate.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +from collections import defaultdict + +for _ in range(int(input())): + n = int(input()) + s = map(int, input().split()) + d = defaultdict(int) + for i in s: d[i] += 1 + result = 0 + for value in s.values(): + if value % 2: + pass + else: + result += value * (value-1) // 2 -- cgit 1.4.1