- 问答
哪里错了,真的求求大佬讲解了
- 2024-12-9 17:52:57 @
# #876. 安修, 奥克苏恩
from collections import defaultdict
# 读取输入
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = list(map(int, input().split()))
# 使用 defaultdict 统计 a + b 和 c + d 的和及其出现次数
dic1 = defaultdict(int)
dic2 = defaultdict(int)
# 统计 a + b 的和
for x in a:
for y in b:
dic1[x + y] += 1
# 统计 c + d 的和
for x in c:
for y in d:
dic2[x + y] += 1
# 计算满足条件的组合数
ans = 0
for k in dic1:
if k in dic2:
ans += dic1[k] * dic2[k]
# 输出结果
if ans == 0:
print("all in")
else:
print(ans)
1 条评论
-
wwww131 LV 3 @ 2024-12-9 19:12:24
mtc佬❤️ ❤️ ❤️
- 1