美团数据研发岗位8.15

最后一个专项编程题没时间提交了,也不知道答案对不对,放上来,如果有ac了的可以互相讨论哟
import sys
if __name__ == "__main__":
    n, m = map(int, sys.stdin.readline().strip().split())
    count = 0
    res = []
    def dfs(x, tmp):
        if len(tmp) == m:
            res.append(tmp.copy())
            global count
            count += 1
            return

        for i in range(x, n+1):
            if not tmp&nbs***bsp;i % tmp[-1] == 0:
                tmp.append(i)
                dfs(x, tmp)
                tmp.pop()
    dfs(1, [])
    # print(res)
    print(count)


#美团##笔试题目#
全部评论

相关推荐

迷茫的大四🐶:哇靠,哥们,啥认证啊,副总裁实习,这么有实力嘛
一起聊美团
点赞 评论 收藏
分享
迷茫的大四🐶:都收获五个了,兄弟那还说啥,不用改了,去玩吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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