結果

問題 No.1674 Introduction to XOR
ユーザー ks2mks2m
提出日時 2021-09-10 21:27:46
言語 Java
(openjdk 23)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 470 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 54,528 KB
最終ジャッジ日時 2024-06-11 22:28:22
合計ジャッジ時間 5,827 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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