QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598402#9168. Square LocatorfosovRE 0ms0kbPython3928b2024-09-28 21:39:482024-09-28 21:39:48

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 21:39:48]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-28 21:39:48]
  • 提交

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

result: