結果
問題 |
No.862 XORでX
|
ユーザー |
![]() |
提出日時 | 2019-12-30 22:33:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 236 ms / 2,000 ms |
コード長 | 1,907 bytes |
コンパイル時間 | 2,453 ms |
コンパイル使用メモリ | 80,056 KB |
実行使用メモリ | 62,068 KB |
最終ジャッジ日時 | 2024-11-15 20:09:49 |
合計ジャッジ時間 | 11,446 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
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); } }