結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー kenkoooo
提出日時 2015-04-17 23:59:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 2,032 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 1,844 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 58,820 KB
最終ジャッジ日時 2024-06-29 01:48:12
合計ジャッジ時間 16,948 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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();
		boolean[] dp = new boolean[1 << 14 + 1];
		for (int i = 0; i < N; i++) {
			dp[sc.nextInt()] = true;
		}
		sc.close();

		for (int i = 0; i < dp.length; i++) {
			if (!dp[i]) {
				continue;
			}
			for (int j = 0; j < dp.length; j++) {
				if (dp[j]) {
					dp[i ^ j] = true;
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < dp.length; i++) {
			if (dp[i]) {
				ans++;
			}
		}
		System.out.println(ans);

	}
}
0