結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー tentententen
提出日時 2020-10-07 16:49:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 810 ms / 5,000 ms
コード長 677 bytes
コンパイル時間 3,908 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 47,572 KB
最終ジャッジ日時 2024-07-20 03:27:22
合計ジャッジ時間 11,143 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] cur = new boolean[1 << 15];
		boolean[] next = new boolean[1 << 15];
		cur[0] = true;
		for (int i = 0; i < n; i++) {
		    int a = sc.nextInt();
		    for (int j = 0; j < (1 <<15); j++) {
		        if (cur[j]) {
		            next[j] = true;
		            next[j ^ a] = true;
		        }
		    }
		    boolean[] tmp = next;
		    next = cur;
		    cur = tmp;
		    Arrays.fill(next, false);
		}
		int count = 0;
		for (boolean b : cur) {
		    if (b) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}
0