题解 | 数组分组
数组分组
https://www.nowcoder.com/practice/9af744a3517440508dbeb297020aca86
def func(three, five, other):
if not other:
if sum(three) == sum(five):
return True
else:
return False
if func(three+other[:1], five, other[1:]):
return True
if func(three, five+other[:1], other[1:]):
return True
while True:
try:
n = int(input())
nums = [int(i) for i in input().split()]
other = []
three = []
five = []
for i in nums:
if i % 5 == 0:
five.append(i)
elif i % 3 == 0:
three.append(i)
else:
other.append(i)
res = func(three, five, other)
if res:
print("true")
else:
print("false")
except:
break
