6 条题解
题解与来源题共享。已有题解默认通过;新增或编辑后需由来源域管理员审核。待审核、驳回题解仅作者和审核管理员可见。来源域:system
-
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
- 难度
- 普及−
- 标签
- 递交数
- 1501
- 已通过
- 250
- 上传者