結果

問題 No.862 XORでX
ユーザー htensaihtensai
提出日時 2019-12-30 22:33:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 1,907 bytes
コンパイル時間 1,890 ms
コンパイル使用メモリ 79,448 KB
実行使用メモリ 62,016 KB
最終ジャッジ日時 2024-04-27 16:28:13
合計ジャッジ時間 9,259 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
53,928 KB
testcase_01 AC 119 ms
54,132 KB
testcase_02 AC 106 ms
52,700 KB
testcase_03 AC 114 ms
54,228 KB
testcase_04 AC 118 ms
54,152 KB
testcase_05 AC 110 ms
53,844 KB
testcase_06 AC 102 ms
52,924 KB
testcase_07 AC 113 ms
52,932 KB
testcase_08 AC 140 ms
53,668 KB
testcase_09 AC 144 ms
54,312 KB
testcase_10 AC 142 ms
54,208 KB
testcase_11 AC 134 ms
53,656 KB
testcase_12 AC 103 ms
52,788 KB
testcase_13 AC 112 ms
53,972 KB
testcase_14 AC 103 ms
53,096 KB
testcase_15 AC 114 ms
54,000 KB
testcase_16 AC 194 ms
59,272 KB
testcase_17 AC 188 ms
59,564 KB
testcase_18 AC 184 ms
59,572 KB
testcase_19 AC 192 ms
59,232 KB
testcase_20 AC 190 ms
61,624 KB
testcase_21 AC 205 ms
61,736 KB
testcase_22 AC 200 ms
60,924 KB
testcase_23 AC 208 ms
61,052 KB
testcase_24 AC 202 ms
61,500 KB
testcase_25 AC 187 ms
60,976 KB
testcase_26 AC 198 ms
61,300 KB
testcase_27 AC 205 ms
62,016 KB
testcase_28 AC 210 ms
61,796 KB
testcase_29 AC 195 ms
61,028 KB
testcase_30 AC 205 ms
61,580 KB
testcase_31 AC 205 ms
61,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int mod = n % 4;
        ArrayList<Integer> list = new ArrayList<>();
        if (x == 1) {
            if (mod == 0) {
                list.add(1);
                list.add(6);
                list.add(100003);
                list.add(100005);
                x = 6;
            } else if (mod == 3) {
                list.add(100003);
                list.add(100005);
                list.add(7);
                x = 6;
            } else if (mod == 2) {
                list.add(100004);
                list.add(100005);
            } else {
                list.add(1);
            }
        } else {
            if (mod == 0) {
                list.add(x);
                list.add(1);
                list.add(100004);
                list.add(100005);
            } else if (mod == 3) {
                if (x % 2 == 0) {
                    list.add(x + 1);
                } else {
                    list.add(x - 1);
                }
                list.add(100004);
                list.add(100005);
            } else if (mod == 2) {
                 if (x % 2 == 0) {
                    list.add(x + 1);
                } else {
                    list.add(x - 1);
                }
                list.add(1);
            } else {
                list.add(x);
            }
        }
        int idx = 2;
        while (list.size() < n) {
            while (idx == x || idx + 1 == x) {
                idx += 2;
            }
            list.add(idx);
            list.add(idx + 1);
            idx += 2;
        }
        StringBuilder sb = new StringBuilder();
        for (int y : list) {
            sb.append(y).append("\n");
        }
        System.out.print(sb);
    }
    
 }
0