题解 | 元素方碑
元素方碑
https://www.nowcoder.com/practice/5c6e7ed4726e41f4ac99a4dedf1e5bb2
import sys
t = int(sys.stdin.readline())
for _ in range(t):
n, a = int(sys.stdin.readline()), list(map(int, sys.stdin.readline().split()))
if sum(a) % n == 0:
s = sum(a[i] for i in range(1, n, 2))
print("YES" if s == sum(a) // n * (n // 2) else "NO")
else:
print("NO")
查看15道真题和解析