結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー kenkooookenkoooo
提出日時 2015-04-16 23:45:39
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 943 bytes
コンパイル時間 4,199 ms
コンパイル使用メモリ 73,404 KB
実行使用メモリ 51,872 KB
最終ジャッジ日時 2023-09-17 21:16:28
合計ジャッジ時間 7,924 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,016 KB
testcase_01 AC 43 ms
48,980 KB
testcase_02 AC 71 ms
50,576 KB
testcase_03 AC 64 ms
50,508 KB
testcase_04 AC 45 ms
48,828 KB
testcase_05 AC 123 ms
50,868 KB
testcase_06 AC 50 ms
48,920 KB
testcase_07 RE -
testcase_08 AC 238 ms
51,728 KB
testcase_09 AC 233 ms
51,328 KB
testcase_10 AC 235 ms
51,684 KB
testcase_11 AC 253 ms
51,524 KB
testcase_12 RE -
testcase_13 AC 43 ms
48,912 KB
testcase_14 AC 55 ms
49,188 KB
testcase_15 AC 239 ms
51,536 KB
testcase_16 AC 63 ms
50,484 KB
testcase_17 AC 238 ms
51,548 KB
testcase_18 RE -
testcase_19 AC 249 ms
51,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;

public class Main {

	public static void main(String[] args) throws Exception {
		int N = nextInt();
		boolean[] a = new boolean[(1 << 14) + 1];
		a[0] = true;
		for (int i = 0; i < N; i++) {
			a[nextInt()] = true;
		}
		for (int i = 1; i < a.length; i++) {
			if (!a[i]) {
				continue;
			}
			for (int j = 1; j < i; j++) {
				if (a[j]) {
					a[i ^ j] = true;
				}
			}
		}

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

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}
}
0