t | def main(): | t | def main(): |
| N = int(input()) | | N = int(input()) |
| result = [] | | result = [] |
| (x, y, z, t) = (0, 0, 0, 0) | | (x, y, z, t) = (0, 0, 0, 0) |
| while x * x * 4 < N: | | while x * x * 4 < N: |
| x += 1 | | x += 1 |
| Y = x | | Y = x |
| while x * x <= N: | | while x * x <= N: |
| while Y and (Y - 1) * (Y - 1) * 3 >= N - x * x: | | while Y and (Y - 1) * (Y - 1) * 3 >= N - x * x: |
| Y -= 1 | | Y -= 1 |
| y = Z = Y | | y = Z = Y |
| while y <= x and x * x + y * y <= N: | | while y <= x and x * x + y * y <= N: |
| while Z and (Z - 1) * (Z - 1) * 2 >= N - x * x - y * y: | | while Z and (Z - 1) * (Z - 1) * 2 >= N - x * x - y * y: |
| Z -= 1 | | Z -= 1 |
| z = t = Z | | z = t = Z |
| while z <= y and x * x + y * y + z * z <= N: | | while z <= y and x * x + y * y + z * z <= N: |
| while t * t > N - x * x - y * y - z * z: | | while t * t > N - x * x - y * y - z * z: |
| t -= 1 | | t -= 1 |
| if x * x + y * y + z * z + t * t == N: | | if x * x + y * y + z * z + t * t == N: |
| result.append((x, y, z, t)) | | result.append((x, y, z, t)) |
| z += 1 | | z += 1 |
| y += 1 | | y += 1 |
| x += 1 | | x += 1 |
| for i in result: | | for i in result: |
| print(i[0], i[1], i[2], i[3]) | | print(i[0], i[1], i[2], i[3]) |
| if __name__ == '__main__': | | if __name__ == '__main__': |
| main() | | main() |