結果

問題 No.1674 Introduction to XOR
ユーザー ks2mks2m
提出日時 2021-09-10 21:27:46
言語 Java19
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 470 bytes
コンパイル時間 2,886 ms
コンパイル使用メモリ 71,176 KB
実行使用メモリ 57,468 KB
最終ジャッジ日時 2023-09-02 15:54:53
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,220 KB
testcase_01 AC 124 ms
55,716 KB
testcase_02 AC 125 ms
55,916 KB
testcase_03 AC 126 ms
55,640 KB
testcase_04 AC 126 ms
55,656 KB
testcase_05 AC 126 ms
55,832 KB
testcase_06 AC 126 ms
55,664 KB
testcase_07 AC 129 ms
55,480 KB
testcase_08 AC 125 ms
55,372 KB
testcase_09 AC 125 ms
55,268 KB
testcase_10 AC 127 ms
55,824 KB
testcase_11 AC 128 ms
53,376 KB
testcase_12 AC 128 ms
53,872 KB
testcase_13 AC 126 ms
55,452 KB
testcase_14 AC 129 ms
55,376 KB
testcase_15 AC 130 ms
57,468 KB
testcase_16 AC 126 ms
55,700 KB
testcase_17 AC 135 ms
55,660 KB
testcase_18 AC 134 ms
55,756 KB
testcase_19 AC 130 ms
55,348 KB
testcase_20 AC 132 ms
55,508 KB
testcase_21 AC 124 ms
55,472 KB
testcase_22 AC 132 ms
55,640 KB
testcase_23 AC 134 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		long b = 0;
		for (int i = 0; i < n; i++) {
			b |= a[i];
		}

		for (int i = 0; i < 63; i++) {
			long x = 1L << i;
			if (x + b == (x ^ b)) {
				System.out.println(x);
				return;
			}
		}
	}
}
0