n | | n | |
| | | |
| N = int(input()) | | N = int(input()) |
n | | n | |
| | | |
| 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: |
n | while Y and (Y - 1) * (Y - 1) * 3 >= N - x * x: | n | while (Y and (Y - 1) * (Y - 1) * 3 >= N - x * x): |
| Y -= 1 | | Y -= 1 |
| y = Z = Y | | y = Z = Y |
n | while y <= x and x * x + y * y <= N: | 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 |
n | while z <= y and x * x + y * y + z * z <= N: | 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 |
t | if x * x + y * y + z * z + t * t == N: | t | 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 |
| | | |