Farz0l1x

Untitled

Feb 17th, 2023
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 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 + 1, end) + f(curr * 2, end)
  8. print(f(1, 12) * f(12, 30))
  9.  
  10. a = [0] * 100
  11. a[1] = 1
  12. for i in range(1, 12):
  13.     if i + 1 <= 12:
  14.         a[i + 1] += a[i]
  15.     if i * 2 <= 12:
  16.         a[i * 2] += a[i]
  17. for i in range(12, 30):
  18.     if i + 1 <= 30:
  19.         a[i + 1] += a[i]
  20.     if i * 2 <= 30:
  21.         a[i * 2] += a[i]
  22. print(a[30])
Advertisement
Add Comment
Please, Sign In to add comment