Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(curr, end):
- if curr < end:
- return 0
- if curr == end:
- return 1
- if curr > end:
- return f(curr - 1, end) + f(curr - 3, end) + f(curr // 3, end)
- print(f(22, 2))
- a = [0] * 100
- a[22] = 1
- for i in range(22, 2, -1):
- if i - 1 >= 2:
- a[i - 1] += a[i]
- if i - 3 >= 2:
- a[i - 3] += a[i]
- if i // 3 >= 2:
- a[i // 3] += a[i]
- print(a[2])
Advertisement
Add Comment
Please, Sign In to add comment