結果

問題 No.862 XORでX
ユーザー ks2mks2m
提出日時 2019-08-09 23:47:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,769 bytes
コンパイル時間 3,544 ms
コンパイル使用メモリ 74,256 KB
実行使用メモリ 64,216 KB
最終ジャッジ日時 2023-09-26 22:12:04
合計ジャッジ時間 15,824 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,812 KB
testcase_01 AC 44 ms
49,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 44 ms
49,256 KB
testcase_05 AC 44 ms
49,280 KB
testcase_06 AC 44 ms
49,492 KB
testcase_07 AC 44 ms
49,248 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 44 ms
49,240 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 44 ms
49,640 KB
testcase_16 AC 453 ms
62,636 KB
testcase_17 AC 437 ms
62,032 KB
testcase_18 AC 437 ms
62,140 KB
testcase_19 AC 428 ms
62,404 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 520 ms
64,216 KB
testcase_25 AC 518 ms
62,412 KB
testcase_26 AC 514 ms
62,124 KB
testcase_27 AC 517 ms
62,492 KB
testcase_28 AC 517 ms
62,356 KB
testcase_29 AC 535 ms
62,356 KB
testcase_30 AC 521 ms
60,260 KB
testcase_31 AC 512 ms
62,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int x = Integer.parseInt(sa[1]);
		br.close();

		int n4 = n % 4;
		if (n4 == 0) n4 = 4;
		int x4 = x % 4;
		int l = x - x4;
		int r = x - x4 + 4;
		int end = n - n4 + 8;
		if (8 <= x && x4 <= n4) end += 4;

		for (int i = 8; i < end; i++) {
			if (l <= i && i < r) {
				continue;
			}
			System.out.println(i);
		}

		switch (n4) {
		case 1:
			System.out.println(x);
			break;
		case 2:
			if (x == 1) {
				System.out.println(2);
				System.out.println(3);
			} else {
				System.out.println(x % 2 == 0 ? x + 1 : x - 1);
				System.out.println(1);
			}
			break;
		case 3:
			if (x == 1) {
				System.out.println(3);
				System.out.println(5);
				System.out.println(7);
			} else if (x < 4) {
				System.out.println(x % 2 == 0 ? x + 1 : x - 1);
				System.out.println(6);
				System.out.println(7);
			} else {
				System.out.println(x % 2 == 0 ? x + 1 : x - 1);
				System.out.println(2);
				System.out.println(3);
			}
			break;
		default:
			if (x == 1) {
				System.out.println(1);
				System.out.println(2);
				System.out.println(4);
				System.out.println(6);
			} else if (x < 4) {
				System.out.println(x);
				System.out.println(1);
				System.out.println(4);
				System.out.println(5);
			} else {
				System.out.println(x);
				System.out.println(1);
				if (x4 < 2) {
					System.out.println(x - x4 + 2);
					System.out.println(x - x4 + 3);
				} else {
					System.out.println(x - x4 + 0);
					System.out.println(x - x4 + 1);
				}
			}
		}
	}
}
0