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

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

verified
وضعیت داوری نهایی: پاسخ نادرست تست 2
terminal
زبان برنامه‌نویسی: Java
schedule
ارسال‌کننده و زمان:
khashayar moeinfar (۵ ماه پیش)
descriptionMain.java ۳۷ خط • ۷۸۴ بایت
1import java.util.*;
2
3class Main{
4
5 public static void main(String[] args) {
6
7
8 Scanner sc = new Scanner(System.in);
9
10 int n = sc.nextInt();
11 int p = sc.nextInt();
12
13 int[] position = new int[]{
14 sc.nextInt(),
15 sc.nextInt()
16 };
17 sc.nextLine();
18
19 String s = sc.nextLine();
20
21 int[] direction = new int[]{
22 p * ((s.contains("E") ? 1 : 0) - (s.contains("W") ? 1 : 0)),
23 p * ((s.contains("S") ? 1 : 0) - (s.contains("N") ? 1 : 0))
24 };
25
26
27 for (int i = 0; i < 2; i++) {
28 position[i] = (((position[i] + direction[i]) % n)+n)%n;
29 }
30
31 System.out.println(position[0]+" "+position[1]);
32
33
34 }
35
36
37}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8