arrow_forward همه ارسال‌ها

جزئیات ارسال کد#570

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Hanif Ganji (۲ سال پیش)
descriptionsolution.py ۳۲ خط • ۶۳۸ بایت
1n, p = map(int, input().split())
2x, y = map(int, input().split())
3direction = input()
4
5
6match direction:
7
8 case "N":
9 step_x, step_y = -1, 0
10 case "S":
11 step_x, step_y = 1, 0
12 case "W":
13 step_x, step_y = 0, -1
14 case "E":
15 step_x, step_y = 0, 1
16 case "NE":
17 step_x, step_y = -1, 1
18 case "SE":
19 step_x, step_y = 1, 1
20 case "SW":
21 step_x, step_y = 1, -1
22 case "NW":
23 step_x, step_y = -1, -1
24
25
26new_x = (x + p * step_x) % n
27new_y = (y + p * step_y) % n
28
29new_x = new_x if new_x >= 0 else new_x + n
30new_y = new_y if new_y >= 0 else new_y + n
31
32print(new_x, new_y)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8