結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー Grenache
提出日時 2016-02-14 18:44:46
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,156 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 3,639 ms
コンパイル使用メモリ 75,556 KB
実行使用メモリ 52,232 KB
最終ジャッジ日時 2024-06-29 12:54:41
合計ジャッジ時間 14,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder183 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        boolean[][] dp = new boolean[2][16384 * 2 + 1];
        dp[0][0] = true;

        for (int i = 1; i <= n; i++) {
        	int a = sc.nextInt();

    		Arrays.fill(dp[i % 2], false);

        	for (int j = 0; j <= 16384 * 2; j++) {
        		if (dp[(i - 1) % 2][j]) {
            		dp[i % 2][j] = true;
        			dp[i % 2][j ^ a] = true;
        		}
        	}
        }

        int ret = 0;
        for (boolean f : dp[n % 2]) {
        	if (f) {
        		ret++;
        	}
        }

        System.out.println(ret);

        sc.close();
    }
}
0