Advertisement
Korotkodul

dp_me

Jun 8th, 2023
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. n = 5
  2. F0 = [0] * (n + 1)
  3. F00 = [0] * (n + 1)
  4. F1 = [0] * (n + 1)
  5. F11 = [0] * (n + 1)
  6. F0[1] = 1
  7. F1[1] = 1
  8. F00[2] = 1
  9. F11[2] = 1
  10. F0[2] = 1
  11. F1[2] = 1
  12.  
  13. for i in range(3,n + 1):
  14.     F0[i] = F0[i-1] + F1[i-1] + F11[i-1]
  15.     F1[i] = F1[i-1] + F0[i-1] + F00[i-1]
  16.     F00[i] = F1[i-1] + F11[i-1]
  17.     F11[i] = F0[i-1] + F00[i-1]
  18.  
  19. print(F0)
  20. print(F1)
  21. print(F00)
  22. print(F11)
  23. #R = F0[n] + F00[n] + F1[n] + F11[n]
  24. #print(R)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement