serega1112

cubes

Jan 12th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import math
  2.  
  3. n = int(input())
  4. res = 'impossible'
  5. cub_root = n**(1/3)
  6. if abs(cub_root - round(cub_root)) < 1e-10:
  7.     cub_root = round(cub_root)
  8. for i in range(math.floor(cub_root) + 1):
  9.     rem = n - i ** 3
  10.     root = rem ** (1/3)
  11.     if abs(root - round(root)) < 1e-10:
  12.         root = round(root)
  13.     if int(root) ** 3 == rem:
  14.         res = f'{i} {int(root)}'
  15.         break
  16. print(res)
Advertisement
Add Comment
Please, Sign In to add comment