結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー hama_du
提出日時 2015-05-12 08:08:44
言語 Java
(openjdk 23)
結果
AC  
実行時間 807 ms / 5,000 ms
コード長 824 bytes
コンパイル時間 3,399 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 66,464 KB
最終ジャッジ日時 2024-07-04 11:45:08
合計ジャッジ時間 21,833 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

/**
 * Created by dhamada on 15/05/12.
 */
public class P184 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        long[] a = new long[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = in.nextLong();
        }

        int ok = 0;
        for (int i = 0 ; i < n ; i++) {
            if (a[i] == 0) {
                continue;
            }
            ok++;
            int found = 0;
            while ((a[i] & (1L<<found)) == 0) {
                found++;
            }
            for (int j = i+1 ; j < n ; j++) {
                if ((a[j] & (1L<<found)) != 0) {
                    a[j] ^= a[i];
                }
            }
        }
        System.out.println(1L<<ok);
    }
}
0