题解 | #数组分组#
数组分组
https://www.nowcoder.com/practice/9af744a3517440508dbeb297020aca86
def f(three,five,other):
if not other:
if sum(three)==sum(five):
return True
else:
return False
else:
return f(three+[other[0]],five,other[1:]) or f(three,five+other[:1],other[1:])
n = input()
l = list(map(int,input().split()))
l3,l5,ll = [],[],[]
for i in l:
if i%3==0:
l3.append(i)
elif i%5==0:
l5.append(i)
else:
ll.append(i)
if f(l3,l5,ll):
print('true')
else:
print('false')