結果

問題 No.396 クラス替え
ユーザー kano_townkano_town
提出日時 2016-07-15 23:16:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 2,942 ms
コンパイル使用メモリ 78,612 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2024-04-23 05:04:08
合計ジャッジ時間 6,171 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
53,012 KB
testcase_01 AC 101 ms
52,920 KB
testcase_02 AC 102 ms
53,016 KB
testcase_03 AC 115 ms
54,088 KB
testcase_04 AC 117 ms
54,352 KB
testcase_05 AC 112 ms
53,904 KB
testcase_06 AC 114 ms
53,964 KB
testcase_07 AC 123 ms
54,264 KB
testcase_08 AC 134 ms
54,172 KB
testcase_09 AC 370 ms
54,136 KB
testcase_10 AC 104 ms
52,848 KB
testcase_11 AC 103 ms
52,616 KB
testcase_12 AC 117 ms
54,380 KB
testcase_13 AC 119 ms
53,812 KB
testcase_14 AC 113 ms
54,036 KB
testcase_15 AC 113 ms
54,016 KB
testcase_16 WA -
testcase_17 AC 113 ms
53,880 KB
testcase_18 AC 114 ms
53,920 KB
testcase_19 AC 111 ms
54,148 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