Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. arr = []
  2.  
  3. def read():
  4. global arr
  5. print(arr[0], end = ' ')
  6. for i in arr[1:]:
  7. print("+", i, end = ' ')
  8. print()
  9.  
  10. def wrk(inp):
  11. global arr
  12. if(inp > 1):
  13. if(inp % 3):
  14. for i in range(inp - 1, inp // 3, -1):
  15. if(i >= inp - i):
  16. arr.append(i)
  17. arr.append(inp - i)
  18. read()
  19. arr = arr[:-1]
  20. else:
  21. arr.append(i)
  22.  
  23. wrk(inp - i)
  24. arr = arr[:-1]
  25. else:
  26. for i in range(inp - 1, inp // 3 - 1, -1):
  27. if(i >= inp - i):
  28. arr.append(i)
  29. arr.append(inp - i)
  30. read()
  31. arr = arr[:-1]
  32. else:
  33. arr.append(i)
  34.  
  35. wrk(inp - i)
  36. arr = arr[:-1]
  37.  
  38. n = int(input())
  39. wrk(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement