結果

問題 No.1674 Introduction to XOR
ユーザー bluemeganebluemegane
提出日時 2021-09-10 22:43:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 1,000 ms
コード長 817 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 63,796 KB
実行使用メモリ 22,940 KB
最終ジャッジ日時 2023-09-02 19:41:50
合計ジャッジ時間 3,642 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,928 KB
testcase_01 AC 59 ms
20,736 KB
testcase_02 AC 59 ms
20,844 KB
testcase_03 AC 60 ms
20,780 KB
testcase_04 AC 61 ms
22,728 KB
testcase_05 AC 59 ms
22,904 KB
testcase_06 AC 60 ms
22,764 KB
testcase_07 AC 59 ms
20,824 KB
testcase_08 AC 59 ms
18,728 KB
testcase_09 AC 59 ms
20,788 KB
testcase_10 AC 59 ms
20,692 KB
testcase_11 AC 61 ms
22,832 KB
testcase_12 AC 60 ms
20,780 KB
testcase_13 AC 60 ms
20,732 KB
testcase_14 AC 59 ms
18,756 KB
testcase_15 AC 60 ms
22,940 KB
testcase_16 AC 59 ms
18,652 KB
testcase_17 AC 59 ms
20,808 KB
testcase_18 AC 59 ms
20,724 KB
testcase_19 AC 59 ms
20,840 KB
testcase_20 AC 60 ms
20,796 KB
testcase_21 AC 60 ms
20,852 KB
testcase_22 AC 61 ms
20,872 KB
testcase_23 AC 59 ms
20,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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, long.Parse);
        getAns(n, a);
    }
    static void getAns(int n, long[] a)
    {
        long x;
        if (n == 1) x = a[0];
        else
        {
            x = a[0] | a[1];
            for (int i = 2; i < n; i++) x |= a[i];
        }
        var onf = new bool[60];
        for (int i = 0; i < 60; i++)
        {
            if (((x >> i) & 1) == 1) onf[i] = true;
        }
        var ans = -1L;
        for (int i = 0; i < 60; i++)
        {
            if (!onf[i]) { ans = 1L << i; break; }
        }
        if (ans == -1) ans = 1L << 60;
        Console.WriteLine(ans);
    }
}
0