結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー bluemeganebluemegane
提出日時 2021-05-17 18:45:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 437 ms / 5,000 ms
コード長 704 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 106,752 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-04-16 07:21:05
合計ジャッジ時間 5,454 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
19,072 KB
testcase_01 AC 29 ms
18,816 KB
testcase_02 AC 31 ms
19,072 KB
testcase_03 AC 30 ms
19,072 KB
testcase_04 AC 29 ms
19,072 KB
testcase_05 AC 30 ms
18,944 KB
testcase_06 AC 30 ms
18,944 KB
testcase_07 AC 419 ms
20,224 KB
testcase_08 AC 397 ms
20,224 KB
testcase_09 AC 293 ms
19,968 KB
testcase_10 AC 340 ms
19,968 KB
testcase_11 AC 426 ms
19,968 KB
testcase_12 AC 31 ms
19,200 KB
testcase_13 AC 28 ms
19,200 KB
testcase_14 AC 35 ms
19,840 KB
testcase_15 AC 437 ms
20,224 KB
testcase_16 AC 32 ms
18,944 KB
testcase_17 AC 135 ms
19,584 KB
testcase_18 AC 399 ms
19,968 KB
testcase_19 AC 84 ms
19,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        a = a.Distinct().ToArray();
        getAns(n, a);
    }
    static void getAns (int n, int [] a)
    {
        var imax = a.Max() * 2;
        var b = new bool[imax + 1];
        b[0] = true;
        foreach (var x in  a)
        {
            for (int i = imax ; i >= 0; i--)
            {
                if (b[i]) b[i ^ x] = true;
            }
        }
        var count = b.Count(x => x == true);
        Console.WriteLine(count);
    }
}
0