QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#639858 | #9227. Henry the Plumber | propane | RE | 17ms | 11880kb | Python3 | 1.1kb | 2024-10-13 23:17:29 | 2024-10-13 23:17:30 |
Judging History
answer
from fractions import Fraction
from math import gcd
def dot(a, b):
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
def minus(a, b):
return (a[0] - b[0], a[1] - b[1], a[2] - b[2])
for _ in range(int(input())):
x1, y1, z1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3, z3 = map(int, input().split())
x4, y4 = map(int, input().split())
p1 = (x1, y1, z1)
p2 = (x2, y2, 0)
p3 = (x3, y3, z3)
p4 = (x4, y4, 0)
if (dot(minus(p3, p1), p2) == 0 and dot(minus(p3, p1), p4) == 0):
print(2)
continue
v2 = x1 * x2 + y1 * y2
v4 = x3 * x4 + y3 * y4
lcm = abs(x2 * x4) // abs(gcd(x2, x4))
t1 = lcm // x2
t3 = lcm // x4
k1 = y4 * t3 - y2 * t1
k2 = v4 * t3 - v2 * t1
if k1 == 0 and k2 != 0:
print(4)
continue
y = Fraction(k2, k1)
x = Fraction(v2 - y * y2, x2)
a = 1
b = -(z1 + z3)
c = z1 * z3 + (x - x1) * (x - x3) + (y - y1) * (y - y3)
if b * b - 4 * a * c >= 0:
print(3)
else:
print(4)
详细
Test #1:
score: 100
Accepted
time: 17ms
memory: 11880kb
input:
2 -1 -1 3 1 1 2 2 3 2 2 5 5 1 3 0 7 6 -2 1 -2
output:
4 3
result:
ok 2 number(s): "4 3"
Test #2:
score: -100
Dangerous Syscalls
input:
100 -13 -5 -7 -19 19 -19 -13 0 -7 15 -20 20 19 -17 18 20 -20 -1 18 -19 -18 15 -14 -19 18 19 -20 6 20 -19 -12 9 1 7 -16 -13 -14 -8 8 -13 -19 16 9 20 -19 19 -18 -11 19 -18 19 20 -8 12 20 -11 -9 18 -19 -18 8 11 -13 12 -18 18 13 8 4 -18 -16 20 17 -19 18 20 -18 -3 20 -19 -17 -20 -5 -18 -19 19 16 15 19 20...
output:
4 4 4 4 4 4 3 4 4 4 3 4 4 3 3 4 3 4 4 4 4 4 4 4 4 4 4 4