QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#421841#6763. Triangle PendantshaletomeRE 3ms10948kbPython33.3kb2024-05-26 07:54:052024-05-26 07:54:05

Judging History

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

  • [2024-05-26 07:54:05]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:10948kb
  • [2024-05-26 07:54:05]
  • 提交

answer

# right behind ya

from math import *
def angle(z,y,a):
    ttt=(z**2+y**2-a**2)/2/y/z
    # if ttt>1:
    #     return 0
    # if ttt<-1:
    #     return pi
    # if abs(ttt)>1:
    #     print("WHAT")
    #     exit()
    return acos(ttt)

    lo=0
    hi=pi
    while hi-lo>0.0000001:
        mid=(hi+lo)/2
        dst=(z-y*cos(mid))**2+(y*sin(mid))**2
        if dst > a*a:
            hi=mid
        else:
            lo=mid
    return (hi+lo)/2

def getcos(x,XX,lenzya):
    return cos(angle(x,XX,lenzya))
    # XM=XX*2/3
    # return (x*x+(3/2*XM)**2-lenzya**2)/3/x/XM

def getmid(z,y,a):

    mid=angle(z,y,a)
    lenzya = (z+y*cos(mid))**2+(y*sin(mid))**2
    lenzya /= 4
    # if lenzya<0:
    #     print("WHAT")
    #     exit()
    return sqrt(lenzya)

def istri(a,b,c):
    return a+b>c and a+c>b and b+c>a

def geths(y,z,a):
    A=angle(y,z,a)
    y1=y
    y2=0
    z1=z*cos(A)
    z2=z*sin(A)
    h1=(y1+z1)/2
    h2=(y2+z2)/2
    th=atan2(h2,h1)
    ya=y*cos(th)
    yb=-y*sin(th)
    za=z*cos(A-th)
    zb=z*sin(A-th)
    return ya,yb,za,zb

def chsl1(x,y,z,a,b,c):
    if not istri(y,z,a):
        return None
    ya,yb,za,zb=geths(y,z,a)
    hh=(ya+za)/2+ getmid(b,c,a)
    if x < hh-0.000001:
        return None
    # print("chsl1",x,y,z,a,b,c,hh, (x-hh)**2, (y-yb)**2+(z-zb)**2)
    return [hh,ya,za]

def chsl2(x,y,z,a,b,c):
    ba,bb,ca,cb=geths(b,c,a)
    if (x+ba)**2+bb**2 <= z**2+0.00001 and (x+ca)**2+cb**2 <= y**2+0.00001:
        # print("chsl2",x,y,z,a,b,c, (x+ba)**2+bb**2,y**2,(x+ca)**2+cb**2,z**2)
        return [x,x+ca,x+ba]
    return None

# def f(x,y,z,a,b,c):
#     th=angle(b,c,a)
    


def h(x,y,z,a,b,c):
    i=0
    for tt in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if ans:=chsl2(*tt):
            for _ in range(3-i):
                ans=ans[-1:]+ans[:-1]
            return ans
        i += 1
    i=0
    for tt in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if ans:=chsl1(*tt):
            for _ in range(3-i):
                ans=ans[-1:]+ans[:-1]
            return ans
        i += 1
    return None

for _ in range(int(input())):
    *og,=map(int,input().split())
    x,y,z,a,b,c=og
    ans = h(x,y,z,a,b,c)
    if ans:
        print(*[-V for V in ans])
        continue
    ans=[]
    # brk=False
    for x,y,z,a,b,c in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if a<abs(z-y):
            continue
        # if not istri(z,y,a):
        #     print("WHAT")
        #     exit()
        lenzya=getmid(z,y,a)

        XXX=getmid(b,c,a)
        XM = XXX*2/3

        costh=getcos(x,XXX,lenzya)
        # if abs(costh)<0.00001:
        #     h(*og)
        #     brk=True
        #     break
        H=sqrt(x*x+XM*XM-2*x*XM*costh)
        ans.append(x*getcos(x,H,XM)*-1)
    # if brk:continue
    print(*ans)

# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ python3 E.py < 1.in
# 1.1547005383792246 1.1547005383792246 1.1547005383792246
# 2.309401076758408 3.418538212273144 3.418538212273144
# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ python3 E.py < 1.in
# -1.000000000000018 -1.000000000000018 -1.000000000000018
# -2.0 -2.9605409356365042 -2.9605409356365042
# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ lp

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 10948kb

input:

2
1 1 1 1 1 1
2 3 3 1 1 1

output:

-0.8164965809277261 -0.8164965809277261 -0.8164965809277261
-2 -2.8660254037844384 -2.8660254037844384

result:

ok 6 numbers

Test #2:

score: -100
Dangerous Syscalls

input:

1000
21 2 14 12 13 4
29 19 13 15 10 17
29 24 15 29 24 23
29 17 30 18 9 25
27 24 30 16 4 15
28 13 17 12 21 16
16 22 10 22 15 8
15 23 24 23 27 13
26 3 27 15 16 17
5 8 20 17 6 12
24 14 13 15 19 13
27 22 18 18 23 30
22 18 14 11 29 28
7 13 22 22 17 11
19 9 16 22 20 17
21 14 20 6 29 25
20 10 19 9 27 27
17...

output:

-13.352348999857675 -2.9358567275868337 -2
-26.206159293104733 -17.770400269788606 -11.125966283811172
-28.027431433359673 -18.318582636182793 -8.243362186282255
-13.391819356908659 -27.018301873523452 -27.0433138814028
-26.53493336692567 -22.066632132649342 -29.616079568529667
-26.967804477491708 -...

result: