QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#598405#9168. Square LocatorfosovRE 0ms0kbPython3932b2024-09-28 21:40:132024-09-28 21:40:14

Judging History

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

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

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

result: