Advertisement
PlotnikovPhilipp

Untitled

Oct 17th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 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. R = string.count('R')
  9. F = string.count('F')
  10. B = string.count('B')
  11.  
  12. """
  13.  
  14.    По оси oX
  15.  
  16. """
  17. if L == 0 and R == 0:
  18.     width = x0 - x1
  19. elif string.index('L') < string.index('R'):
  20.     if L > R:
  21.         width = x0 + x1 + w*(R + L - 1)
  22.     elif L == R:
  23.         width = x0 + (w - x1) + w*(L + R - 1)
  24. elif string.index('R') < string.index('L'):
  25.     if R > L:
  26.         width = (w - x0) + (w - x1) + w*(R + L - 1)
  27.     elif R == L:
  28.         width = (w - x0) + x1 + w*(R + L - 1)
  29.  
  30.  
  31. """
  32.  
  33.    По оси oY
  34.  
  35. """
  36. if F == 0 and B == 0:
  37.     height = y0 - y1
  38. elif string.index('F') < string.index('B'):
  39.     if F > B:
  40.         height = y0 + y1 + d*(F + B - 1)
  41.     elif F == B:
  42.         height = y0 + (d - y1) + d*(F + B - 1)
  43. elif string.index('B') < string.index('F'):
  44.     if B > F:
  45.         height = (d - y0) + (d - y1) + d*(F + B - 1)
  46.     elif B == F:
  47.         height = (d - y0) + y1 + d*(F + B - 1)
  48. result = math.sqrt(height**2 + width**2)
  49. print(round(result, 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement