QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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)
详细
Test #1:
score: 0
Runtime Error
input:
36 5 10 41
output:
6 -1 2 3 1 4 5