QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#598405 | #9168. Square Locator | fosov | RE | 0ms | 0kb | Python3 | 932b | 2024-09-28 21:40:13 | 2024-09-28 21:40:14 |
answer
from math import isqrt
A, B, C, D = map(int, input().split())
a = isqrt(A)
k = (2 * A + B - D) // (2 * a)
# assert(((2 * A + B - D) % (2 * a)) == 0)
m = isqrt(4 * k * k - 4 * 2 * (k * k - B))
# assert(4 * k * k - 4 * 2 * (k * k - B) > 0)
bd = [
[(-2 * k + m) // 4, 0, 0, 0],
[(-2 * k - m) // 4, 0, 0, 0],
[(2 * k + m) // 4, 0, 0, 0],
[(2 * k - m) // 4, 0, 0, 0]
]
for i in range(0, 2):
bd[i][1] = k + bd[i][0]
bd[i][2] = a - bd[i][1]
bd[i][3] = a + bd[i][0]
for i in range(2, 4):
bd[i][1] = k - bd[i][0]
bd[i][2] = bd[i][1] - a
bd[i][3] = a - bd[i][0]
ax, ay = 0, a
for i in range(4):
bx, by, dx, dy = bd[i]
cx = dx - ax + bx
cy = dy - ay + by
if (bx * bx + by * by != B): continue
if (cx * cx + cy * cy != C): continue
if (dx * dx + dy * dy != D): continue
print(f"{ay} {bx} {by} {cx} {cy} {dx} {dy}")
exit(1)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
36 5 10 41
output:
6 -1 2 3 1 4 5