結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー htensai
提出日時 2019-12-30 10:24:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 661 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 74,736 KB
実行使用メモリ 47,576 KB
最終ジャッジ日時 2024-07-02 21:29:51
合計ジャッジ時間 10,780 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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();
        int count = (int)(Math.pow(2, 15));
        boolean[] dp = new boolean[count];
        dp[0] = true;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            for (int j = 0; j < count; j++) {
                if (dp[j]) {
                    dp[j ^ a] = true;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < count; i++) {
            if (dp[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
0