3 条题解
-
0
n = int(input()) a = list(map(int, input().split()))
pre_sum = [0] * (n + 1) for i in range(1, n + 1): pre_sum[i] = pre_sum[i - 1] + a[i - 1]
total = pre_sum[n] if total % 3 != 0: print(0) else: target = total // 3 res = 0 count = 0
for j in range(1, n): if pre_sum[j] == 2 * target: res += count if pre_sum[j] == target: count += 1 print(res)
信息
- ID
- 513
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 284
- 已通过
- 49
- 上传者