fork(60) download
  1. def divide(arr, depth, m):
  2. if len(complements) <= depth:
  3. complements.append(2 ** (depth + 2) + 1)
  4. complement = complements[depth]
  5. for i in range(2):
  6. if complement - arr[i] <= m:
  7. arr[i] = [arr[i], complement - arr[i]]
  8. divide(arr[i], depth + 1, m)
  9.  
  10. m = int(raw_input())
  11.  
  12. arr = [1, 2]
  13. complements = []
  14.  
  15. divide(arr, 0, m)
  16. print arr
Success #stdin #stdout 0.08s 10872KB
stdin
16
stdout
[[[[1, 16], [8, 9]], [[4, 13], [5, 12]]], [[[2, 15], [7, 10]], [[3, 14], [6, 11]]]]