結果

問題 No.396 クラス替え
ユーザー kano_townkano_town
提出日時 2016-07-15 23:19:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 401 ms / 1,000 ms
コード長 922 bytes
コンパイル時間 2,956 ms
コンパイル使用メモリ 71,660 KB
実行使用メモリ 56,544 KB
最終ジャッジ日時 2023-08-11 00:07:05
合計ジャッジ時間 6,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,200 KB
testcase_01 AC 120 ms
55,696 KB
testcase_02 AC 120 ms
55,724 KB
testcase_03 AC 120 ms
56,300 KB
testcase_04 AC 119 ms
55,864 KB
testcase_05 AC 121 ms
55,772 KB
testcase_06 AC 121 ms
55,976 KB
testcase_07 AC 129 ms
56,388 KB
testcase_08 AC 143 ms
55,992 KB
testcase_09 AC 401 ms
56,016 KB
testcase_10 AC 118 ms
56,168 KB
testcase_11 AC 120 ms
55,684 KB
testcase_12 AC 123 ms
56,124 KB
testcase_13 AC 118 ms
56,284 KB
testcase_14 AC 119 ms
55,960 KB
testcase_15 AC 119 ms
56,544 KB
testcase_16 AC 120 ms
56,060 KB
testcase_17 AC 119 ms
53,776 KB
testcase_18 AC 120 ms
55,724 KB
testcase_19 AC 118 ms
56,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder396 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        long X = sc.nextLong();
        long Y = sc.nextLong();
        boolean flip = false;

        long buf = X;
        while (buf > 0) {
            buf -= M * 2;
        }
        buf += M * 2;
        if (buf > M) {
            buf = M * 2 - buf + 1;
        }

        long add1 = (M - buf) * 2 + 1;
        long add2 = M * 2 - add1;

        while (buf <= N) {
            if (buf == Y) {
                System.out.println("YES");
                return;
            }
            if (!flip) {
                buf += add1;
                flip = !flip;
            } else {
                buf += add2;
                flip = !flip;
            }
        }

        System.out.println("NO");
    }
}
0