题解 | #数组分组#

数组分组

https://www.nowcoder.com/practice/9af744a3517440508dbeb297020aca86

m = int(input())
o = list(map(int, input().split()))
five = []
three = []
other = []
for x in o:
    if x % 5 == 0:
        five.append(x)
    elif x % 3 == 0:
        three.append(x)
    else:
        other.append(x)

num1 = abs(sum(five) - sum(three))
num2 = sum(other)
num3 = num1 + num2
if num3 % 2 == 0:
    num4 = num3 // 2
    b = {0}
    for x in other:
        b = b | set(y+x for y in b)
    if num4 in b:
        print('true')
    else:
        print('false')
else:
    print('false')

全部评论

相关推荐

10-30 23:23
已编辑
中山大学 Web前端
去B座二楼砸水泥地:这无论是个人素质还是专业素质都👇拉满了吧
点赞 评论 收藏
分享
点赞 1 评论
分享
牛客网
牛客企业服务