結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー spacia
提出日時 2016-01-17 18:50:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 437 ms / 5,000 ms
コード長 848 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 78,220 KB
実行使用メモリ 48,252 KB
最終ジャッジ日時 2024-06-29 12:35:16
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int max = 1 << 15;
		boolean[] dp = new boolean[max];
		boolean[] check = new boolean[max];
		
		int n = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ");
		int[] nums = new int[n];
		for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(line[i]);
		
		for (int i = 0; i < n; i++) {
			dp[nums[i]] = true;
			for (int j = 0; j < max; j++) {
				if (!dp[j]) continue;
				dp[j^nums[i]] = true;
				check[j^nums[i]] = true;
			}
			Arrays.fill(check , false);
		}
		
		int ans = 0;
		for (int i = 0; i < max; i++)
			if (dp[i]) ans++;
		
		out(ans);
	}
}
0