t | | t | """Untitled1.ipynb |
| | | |
| | | Automatically generated by Colaboratory. |
| | | |
| | | Original file is located at |
| | | https://colab.research.google.com/drive/1ZaiaJmjYhd-XcflkUo_Opr5EfMecgUnz |
| | | """ |
| N = int(input()) | | N = int(input()) |
| x = 0 | | x = 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 = Y | | y = Y |
| Z = 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 = Z | | z = Z |
| t = 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: |
| print(x, y, z, t) | | print(x, y, z, t) |
| z += 1 | | z += 1 |
| y += 1 | | y += 1 |
| x += 1 | | x += 1 |