Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def readArray():
- return tuple(map(int, input().split()))
- _, m, k = readArray()
- a = readArray()
- dedup = set(a)
- def step(n, depth, current):
- candidates = tuple(filter(lambda x: n % x == 0, dedup))
- if depth == k:
- try:
- x = tuple(filter(lambda i: n == i, candidates))[0]
- except IndexError:
- return None
- else:
- return [*current, x]
- for i in candidates:
- x = step(n // i, depth + 1, [*current, i])
- if x == None:
- continue
- else:
- return x
- return None
- print([1 + a.index(i) for i in step(m, 1, [])])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement