31 lines
594 B
Python
31 lines
594 B
Python
from collections import Counter
|
|
import sys
|
|
input = sys.stdin.readline
|
|
|
|
T = int(input())
|
|
n, A = int(input()), list(map(int, input().split()))
|
|
m, B = int(input()), list(map(int, input().split()))
|
|
|
|
sumA = []
|
|
for i in range(n) :
|
|
currentSum = 0
|
|
for a in A[i:] :
|
|
currentSum += a
|
|
sumA.append(currentSum)
|
|
|
|
sumB = []
|
|
for i in range(m) :
|
|
currentSum = 0
|
|
for b in B[i:] :
|
|
currentSum += b
|
|
sumB.append(currentSum)
|
|
|
|
countA = Counter(sumA)
|
|
countB = Counter(sumB)
|
|
|
|
ans = 0
|
|
for key in countA :
|
|
target = T - key
|
|
ans += countA[key]*countB[target]
|
|
|
|
print(ans) |