結果

問題 No.396 クラス替え
ユーザー kano_townkano_town
提出日時 2016-07-15 23:08:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 3,421 ms
コンパイル使用メモリ 74,880 KB
実行使用メモリ 54,420 KB
最終ジャッジ日時 2024-04-23 05:03:15
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
53,016 KB
testcase_01 AC 126 ms
54,052 KB
testcase_02 AC 110 ms
53,128 KB
testcase_03 WA -
testcase_04 AC 112 ms
54,108 KB
testcase_05 WA -
testcase_06 AC 112 ms
53,848 KB
testcase_07 AC 107 ms
53,156 KB
testcase_08 AC 124 ms
53,044 KB
testcase_09 AC 315 ms
54,120 KB
testcase_10 AC 116 ms
54,116 KB
testcase_11 AC 108 ms
53,952 KB
testcase_12 AC 116 ms
54,132 KB
testcase_13 AC 113 ms
54,000 KB
testcase_14 AC 100 ms
52,652 KB
testcase_15 AC 111 ms
54,096 KB
testcase_16 AC 123 ms
54,224 KB
testcase_17 AC 111 ms
54,136 KB
testcase_18 WA -
testcase_19 AC 113 ms
53,860 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();

        long buf = X;
        while (buf > 0) {
            buf -= M * 2;
        }
        buf += M * 2;
        if (buf > M )   buf = (buf - M) * 2 - 1;
        
        boolean flip = false;
        long add1 = (M - buf) * 2 + 1;
        long add2 = M * 2 - add1;
        
        while (buf < N) {
            if (!flip) {
                buf += add1;
                flip = !flip;
            } else {
                buf += add2;    
                flip = !flip;
            }
            if (buf == Y) {
                System.out.println("YES");
                return;
            }
        }

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