반응형
import sys
def find_sum_dic(num, array):
sum_dic = {}
for i in range(num):
for j in range(i+1,num+1):
s = sum(array[i:j])
if s in sum_dic:
sum_dic[s] += 1
else:
sum_dic[s] = 1
return sum_dic
if __name__ == '__main__':
T = int(input())
n = int(input())
A = list(map(int,sys.stdin.readline().split()))
m = int(input())
B = list(map(int,sys.stdin.readline().split()))
sum_A = find_sum_dic(n, A)
sum_B = find_sum_dic(m, B)
num = 0
for ka in sum_A.keys():
if T - ka in sum_B:
num += sum_A[ka]*sum_B[T - ka]
print(num)
반응형