QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515594#9168. Square Locatorucup-team045Compile Error//C++20675b2024-08-11 19:01:252024-08-11 19:01:26

Judging History

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

  • [2024-08-11 19:01:26]
  • 评测
  • [2024-08-11 19:01:25]
  • 提交

answer

# from math import isqrt
from math import sqrt

def isqrt(x):
    t = int(sqrt(x))
    while t * t > x: t -= 1
    while (t + 1) * (t + 1) <= x: t += 1
    return t

A, B, C, D = map(int, input().split())

l = isqrt(A)

# d = x - y
# y = x - d

d = (B - D) // (2 * l)

# x^2 + (l - (x - d))^2 = B
# x^2 + l^2 - 2a(x - d) + x^2 - 2xd + d^2 = B
# 2x^2 - (2a + 2d)x + l^2 + 2ad + d^2 - B = 0

# a = 2, b = - (2a + 2d), c = a^2 + 2ad + d^2 - B

a = 2
b = - (2 * l + 2 * d)
c = l * l + 2 * l * d + d * d - B

delta2 = b * b - 4 * a * c

delta = isqrt(delta2)

x = (-b + delta) // (2 * a)
y = x - d
print(l, -x, l - y, -x + y, l - y - x, y, l - x)

Details

answer.code:1:3: error: invalid preprocessing directive #from
    1 | # from math import isqrt
      |   ^~~~
answer.code:14:3: error: invalid preprocessing directive #d
   14 | # d = x - y
      |   ^
answer.code:15:3: error: invalid preprocessing directive #y
   15 | # y = x - d
      |   ^
answer.code:19:3: error: invalid preprocessing directive #x
   19 | # x^2 + (l - (x - d))^2 = B
      |   ^
answer.code:20:3: error: invalid preprocessing directive #x
   20 | # x^2 + l^2 - 2a(x - d) + x^2 - 2xd + d^2 = B
      |   ^
answer.code:21:3: error: "2x" after # is not a positive integer
   21 | # 2x^2 - (2a + 2d)x + l^2 + 2ad + d^2 - B = 0
      |   ^~
answer.code:23:3: error: invalid preprocessing directive #a
   23 | # a = 2, b = - (2a + 2d), c = a^2 + 2ad + d^2 - B
      |   ^
answer.code:2:1: error: ‘from’ does not name a type
    2 | from math import sqrt
      | ^~~~