結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー htensaihtensai
提出日時 2019-11-26 08:03:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 2,842 ms
コンパイル使用メモリ 74,664 KB
実行使用メモリ 54,244 KB
最終ジャッジ日時 2024-04-23 23:20:04
合計ジャッジ時間 6,931 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,376 KB
testcase_01 AC 129 ms
41,568 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 123 ms
41,332 KB
testcase_06 WA -
testcase_07 AC 205 ms
45,744 KB
testcase_08 AC 204 ms
45,672 KB
testcase_09 AC 194 ms
44,736 KB
testcase_10 AC 207 ms
45,536 KB
testcase_11 AC 213 ms
45,940 KB
testcase_12 AC 107 ms
41,184 KB
testcase_13 AC 122 ms
41,536 KB
testcase_14 AC 191 ms
46,136 KB
testcase_15 AC 212 ms
45,924 KB
testcase_16 WA -
testcase_17 AC 171 ms
42,596 KB
testcase_18 AC 206 ms
45,440 KB
testcase_19 AC 170 ms
42,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[][] arrays = new boolean[n][];
		for (int i = 0; i < n; i++) {
		    arrays[i] = getBinary(sc.nextInt());
		}
		long total = 1;
		for (int i = 0; i < 16; i++) {
		    boolean hasTrue = false;
		    for (int j = 0; j < n; j++) {
		        if (arrays[j][i]) {
		            hasTrue = true;
		            break;
		        }
		    }
		    if (hasTrue) {
		        total *= 2;
		    }
		}
		System.out.println(total);
	}
	
	static boolean[] getBinary(int x) {
	    boolean[] ans = new boolean[16];
	    for (int i = 0; i < ans.length; i++) {
	        ans[i] = (x % 2 == 1);
	        x /= 2;
	    }
	    return ans;
	}
}
0