Farz0l1x

Untitled

Feb 17th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def f(curr, end):
  2.     if curr < end:
  3.         return 0
  4.     if curr == end:
  5.         return 1
  6.     if curr > end:
  7.         return f(curr - 8, end) + f(curr // 2, end)
  8. print(f(102, 43) * f(43, 5))
  9.  
  10. a = [0] * 1000
  11. a[102] = 1
  12. for i in range(102, 43, -1):
  13.     if i - 8 >= 43:
  14.         a[i - 8] += a[i]
  15.     if i // 2 >= 43:
  16.         a[i // 2] += a[i]
  17. for i in range(43, 5, -1):
  18.     if i - 8 >= 5:
  19.         a[i - 8] += a[i]
  20.     if i // 2 >= 5:
  21.         a[i // 2] += a[i]
  22. print(a[5])
Advertisement
Add Comment
Please, Sign In to add comment