题解 | #数组分组#
数组分组
https://www.nowcoder.com/practice/9af744a3517440508dbeb297020aca86
n=input()
s=list(map(int,input().split()))
five=[]
three=[]
other=[]
for i in s:
if i%5==0:
five.append(i)
elif i%3==0:
three.append(i)
else:
other.append(i)
diff=abs(sum(five)-sum(three))
def func(s,a,b):
if len(s)==0:
if abs(sum(a)-sum(b))==diff:
return True
else:
if func(s[1:],a+[s[0]],b) or func(s[1:],a,b+[s[0]]):
return True
print('true' if func(other,[],[]) else 'false')
爱玛科技公司福利 6人发布