合法的顺序一共有几种

👁️ 0 人浏览 💬 0 人评论 ❤️ 添加收藏

箭头一改,就开不了工

排得开

排不开

七个构建任务编号 0~6(a, b) 表示 a 做完才能做 b

from itertools import permutations
DEP = [(0, 1), (0, 2), (1, 3), (2, 3), (3, 4), (4, 5), (4, 6)]
N = 7

def ok(p):
    return all(p.index(a) < p.index(b) for a, b in DEP)

print(sum(1 for p in permutations(range(N)) if ok(p)))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论