Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import math
- w, d = [int(i) for i in input().split()]
- x0, y0 = [int(i) for i in input().split()]
- x1, y1 = [int(i) for i in input().split()]
- string = input()
- L = string.count('L')
- R = string.count('R')
- F = string.count('F')
- B = string.count('B')
- """
- По оси oX
- """
- if L == 0 and R == 0:
- width = x0 - x1
- elif string.index('L') < string.index('R'):
- if L > R:
- width = x0 + x1 + w*(R + L - 1)
- elif L == R:
- width = x0 + (w - x1) + w*(L + R - 1)
- elif string.index('R') < string.index('L'):
- if R > L:
- width = (w - x0) + (w - x1) + w*(R + L - 1)
- elif R == L:
- width = (w - x0) + x1 + w*(R + L - 1)
- """
- По оси oY
- """
- if F == 0 and B == 0:
- height = y0 - y1
- elif string.index('F') < string.index('B'):
- if F > B:
- height = y0 + y1 + d*(F + B - 1)
- elif F == B:
- height = y0 + (d - y1) + d*(F + B - 1)
- elif string.index('B') < string.index('F'):
- if B > F:
- height = (d - y0) + (d - y1) + d*(F + B - 1)
- elif B == F:
- height = (d - y0) + y1 + d*(F + B - 1)
- result = math.sqrt(height**2 + width**2)
- print(round(result, 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement