t | n = int(input()) | t | N = int(input()) |
| x = int(n ** 0.5 / 4) | | x = int(N ** 0.5 / 4) |
| while x * x <= n: | | while x * x <= N: |
| y = int((n - x * x) ** 0.5 / 3) | | y = int((N - x * x) ** 0.5 / 3) |
| while y <= x and x * x + y * y <= n: | | while y <= x and x * x + y * y <= N: |
| z = int((n - x * x - y * y) ** 0.5 / 2) | | z = int((N - x * x - y * y) ** 0.5 / 2) |
| while z <= y and x * x + y * y + z * z <= n: | | while z <= y and x * x + y * y + z * z <= N: |
| if n - x * x - y * y - z * z <= z * z: | | if N - x * x - y * y - z * z <= z * z: |
| t = int((n - x * x - y * y - z * z) ** 0.5) | | t = int((N - x * x - y * y - z * z) ** 0.5) |
| if x * x + y * y + z * z + t * t == n: | | if x * x + y * y + z * z + t * t == N: |
| print(x, y, z, t) | | print(x, y, z, t) |
| z += 1 | | z += 1 |
| y += 1 | | y += 1 |
| x += 1 | | x += 1 |