Advertisement
PlotnikovPhilipp

Untitled

Oct 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import math
  3. w, d = [int(i) for i in input().split()]
  4. x0, y0 = [int(i) for i in input().split()]
  5. x1, y1 = [int(i) for i in input().split()]
  6. string = input()
  7. L = string.count('L')
  8. print(L)
  9. R = string.count('R')
  10. F = string.count('F')
  11. B = string.count('B')
  12.  
  13. """
  14.  
  15.    По оси oX
  16.  
  17. """
  18. width = 0
  19. kx = L + R - 1
  20. if kx < 0:
  21.     kx = 0
  22. if L == 0 and R == 0:
  23.     width = x0 - x1
  24. elif L > R:
  25.     width = x0 + x1 + w*kxky
  26. elif L == R:
  27.     if string.find('L') < string.find('R'):
  28.         width = x0 + (w - x1) + w*kx
  29.     elif string.find('R') < string.find('L'):
  30.         width = (w - x0) + x1 + w*kx
  31. elif R > L:
  32.     width = (w - x0) + (w - x1) + w*kx
  33.  
  34.  
  35. """
  36.  
  37.    По оси oY
  38.  
  39. """
  40. height = 0
  41. ky = F + B - 1
  42. if ky < 0:
  43.     ky = 0
  44. if F == 0 and B == 0:
  45.     height = y0 - y1
  46.  
  47. if F > B:
  48.     height = y0 + y1 + d*ky
  49. elif F == B:
  50.     if string.find('F') < string.find('B'):
  51.         height = y0 + (d - y1) + d*ky
  52.     elif string.find('B') < string.find('F'):
  53.         height = (d - y0) + y1 + d*ky
  54. elif B > F:
  55.     height = (d - y0) + (d - y1) + d*ky
  56. result = math.sqrt(height**2 + width**2)
  57. print(round(result, 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement