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

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

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