f | N = int(input()) | f | N = int(input()) |
n | a = 0 | n | |
| while 4 * a ** 2 < N: | | |
| a += 1 | | |
| B = a | | |
| while a * a <= N: | | |
| while B and 3 * (B - 1) ** 2 >= N - a * a: | | |
| B -= 1 | | |
| b = C = B | | |
| while b <= a and a ** 2 + b ** 2 <= N: | | |
| while C and 2 * (C - 1) ** 2 >= N - a ** 2 - b ** 2: | | |
| C -= 1 | | |
| c = d = C | | |
| while c <= b and a ** 2 + b ** 2 + c ** 2 <= N: | | |
| while d ** 2 > N - a ** 2 - b ** 2 - c ** 2: | | |
| d -= 1 | | |
| if a ** 2 + b ** 2 + c ** 2 + d ** 2 == N: | | |
| print(a, b, c, d) | | |
| c += 1 | | |
| b += 1 | | |
| a += 1 | | |
| | | |
t | | t | x = 0 |
| | | while 4 * (x ** 2) < N: |
| | | x += 1 |
| | | Y = x |
| | | while x ** 2 <= N: |
| | | while Y and 3 * (Y - 1) ** 2 >= N - x ** 2: |
| | | Y -= 1 |
| | | y = Z = Y |
| | | while y <= x and x ** 2 + y ** 2 <= N: |
| | | while Z and 2*(Z - 1) ** 2 >= N - x ** 2 - y ** 2: |
| | | Z -= 1 |
| | | z = t = Z |
| | | while z <= y and x ** 2 + y ** 2 + z ** 2 <= N: |
| | | while t ** 2 > N - x ** 2 - y ** 2 - z ** 2: |
| | | t -= 1 |
| | | if x ** 2 + y ** 2 + z ** 2 + t ** 2 == N: |
| | | print(x, y, z, t) |
| | | z += 1 |
| | | y += 1 |
| | | x += 1 |
| | | |