Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- inp = open('input.txt', 'r')
- otp = open('output.txt', 'w')
- strinp = inp.readline() # Where is my boat
- Ux, Uy = map(float, strinp.split())
- strinp = inp.readline() # Direction of my boat (vec a)
- ax, ay = map(float, strinp.split())
- strinp = inp.readline() # Direction of my 'mach'
- mx, my = map(float, strinp.split())
- strinp = inp.readline() # Where empty boats are
- wx, wy = map(float, strinp.split())
- corner_of_enemies = 90 - math.acos((ax * (wx - Ux) + ay * (wy - Uy)) / ((ax**2 + ay**2)**0.5 * ((wx - Ux)**2 + (wy - Uy)**2)**0.5))*180/math.pi
- corner_of_mach = abs(math.acos(1 / ((mx**2 + my**2 + 1)**0.5)) * 180 / math.pi)
- if mx*(ay-Uy) - my*(ax-Ux) > 0:
- corner_of_mach *= -1
- orientation = 0
- if ax == 0:
- if wx < ax+Ux:
- if ay > 0:
- orientation = 1
- else:
- orientation = -1
- elif wx > ax+Ux:
- if ay > 0:
- orientation = -1
- else:
- orientation = 1
- elif wy > (((ax+Ux)*Uy - (ay+Uy)*Ux)+((ay+Uy) - Uy)*wx) / ax:
- if ax > 0:
- orientation = 1
- else:
- orientation = -1
- elif wy < (((ax+Ux)*Uy - (ay+Uy)*Ux)+((ay+Uy) - Uy)*wx) / ax:
- if ax > 0:
- orientation = -1
- else:
- orientation = 1
- if abs(corner_of_enemies) < 60 and abs(corner_of_mach) < 60 and orientation != 0:
- otp.write(str(orientation) + '\n')
- otp.write(str(round(corner_of_enemies, 2)) + '\n')
- otp.write(str(round(corner_of_mach, 2)) + '\n')
- otp.write('Ahtung!')
- else:
- otp.write('0')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement