题解 | #数组分组#

数组分组

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:])

= input()

= 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')

全部评论

相关推荐

05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务