题意是说:同样的和只算一种测试题答案。比如
5
1 2 2 3 4
这组数据,输出应该是2,因为1+2=3和1+2=3算一种,2+2=4和1+3=4算一种,所以需要多加一个检测,用于判断该和之前是不是已经存在了。
n = int(input())
l = list(map(int,input().split()))
cnt = 0
from itertools import combinations
check = []
for i in combinations(l,2):
if i[0]+i[1] in l and i[0]+i[1] not in check:
cnt += 1
check.append(i[0]+i[1])
print(cnt)