Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- fin = open("input.txt", "r")
- shipX, shipY = map(float, fin.readline().split())
- shipDirectionVecX, shipDirectionVecY = map(float, fin.readline().split())
- shipLeanVecX, shipLeanVecY = map(float, fin.readline().split())
- enemyX, enemyY = map(float, fin.readline().split())
- fin.close()
- leftsideVecX = -shipDirectionVecY
- leftsideVecY = shipDirectionVecX
- rightsideVecX = shipDirectionVecY
- rightsideVecY = -shipDirectionVecX
- verticalAngle = (1 / math.sqrt(1 + shipLeanVecX ** 2 +
- shipLeanVecY ** 2))
- fout = open("output.txt", "w")
- if (verticalAngle > 1 / 2):
- verticalAngle = math.acos(verticalAngle) * (180 / math.pi)
- leftVerticalPitch = (shipLeanVecX * leftsideVecX + shipLeanVecY * leftsideVecY) / (
- math.sqrt(1 + shipLeanVecX ** 2 + shipLeanVecY ** 2) * math.sqrt(leftsideVecX ** 2 + leftsideVecY ** 2))
- if (leftVerticalPitch > 0):
- leftVerticalPitch = verticalAngle
- rightVerticalPitch = -verticalAngle
- else:
- leftVerticalPitch = -verticalAngle
- rightVerticalPitch = verticalAngle
- else:
- fout.write("kek1")
- exit(0)
- enemyVecX = enemyX - shipX
- enemyVecY = enemyY - shipY
- horizontalAngle = (enemyVecX * shipDirectionVecX + enemyVecY * shipDirectionVecY) / (
- math.sqrt(enemyVecX ** 2 + enemyVecY ** 2) * math.sqrt(shipDirectionVecX ** 2 + shipDirectionVecY ** 2))
- if (abs(horizontalAngle) <= math.sqrt(3) / 2):
- horizontalAngle = math.acos(horizontalAngle) * (180 / math.pi)
- else:
- fout.write("kek2")
- exit(0)
- boardSide = (leftsideVecX * enemyVecX + leftsideVecY * enemyVecY) / (
- math.sqrt(leftsideVecX ** 2 + leftsideVecY ** 2) * math.sqrt(enemyVecX ** 2 + enemyVecY ** 2))
- if (boardSide >= 0):
- boardSide = 1
- else:
- boardSide = -1
- fout.write(str(boardSide) + "\n")
- fout.write(str(-(horizontalAngle - 90)) + "\n")
- fout.write(str(verticalAngle) + "\n")
- fout.write("au-revoir")
- fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement