結果

問題 No.396 クラス替え
ユーザー htensaihtensai
提出日時 2019-12-18 12:18:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 920 bytes
コンパイル時間 3,842 ms
コンパイル使用メモリ 71,360 KB
実行使用メモリ 49,728 KB
最終ジャッジ日時 2023-09-20 09:25:40
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,384 KB
testcase_01 AC 40 ms
49,232 KB
testcase_02 AC 40 ms
49,128 KB
testcase_03 AC 40 ms
49,460 KB
testcase_04 AC 41 ms
49,372 KB
testcase_05 AC 39 ms
49,432 KB
testcase_06 AC 40 ms
49,296 KB
testcase_07 AC 40 ms
49,308 KB
testcase_08 AC 40 ms
49,192 KB
testcase_09 AC 39 ms
49,120 KB
testcase_10 AC 41 ms
49,728 KB
testcase_11 AC 41 ms
49,440 KB
testcase_12 AC 40 ms
47,440 KB
testcase_13 AC 42 ms
49,280 KB
testcase_14 AC 41 ms
49,132 KB
testcase_15 AC 39 ms
49,700 KB
testcase_16 AC 41 ms
49,192 KB
testcase_17 AC 40 ms
49,492 KB
testcase_18 AC 39 ms
47,448 KB
testcase_19 AC 41 ms
49,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int n = Integer.parseInt(first[0]);
        int m = Integer.parseInt(first[1]);
        String[] second = br.readLine().split(" ", 2);
        int x = Integer.parseInt(second[0]);
        int y = Integer.parseInt(second[1]);
        if (getClass(x, m) == getClass(y, m)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    
    static int getClass(int x, int m) {
        if ((x - 1) / m % 2 == 0) {
            if (x % m == 0) {
                return m;
            } else {
                return x % m;
            }
        } else {
            return m - (x - 1) % m;
        }
    }
}
0