結果

問題 No.2300 Substring OR Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-27 08:57:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 917 ms
コンパイル使用メモリ 111,404 KB
実行使用メモリ 47,440 KB
最終ジャッジ日時 2024-04-14 21:41:53
合計ジャッジ時間 4,146 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
25,008 KB
testcase_01 AC 28 ms
25,184 KB
testcase_02 AC 28 ms
25,176 KB
testcase_03 AC 58 ms
28,016 KB
testcase_04 AC 54 ms
27,612 KB
testcase_05 AC 59 ms
30,428 KB
testcase_06 AC 45 ms
24,372 KB
testcase_07 AC 126 ms
44,576 KB
testcase_08 AC 69 ms
31,852 KB
testcase_09 AC 61 ms
30,392 KB
testcase_10 AC 107 ms
44,284 KB
testcase_11 AC 117 ms
45,496 KB
testcase_12 AC 126 ms
44,652 KB
testcase_13 AC 132 ms
47,440 KB
testcase_14 AC 97 ms
41,364 KB
testcase_15 AC 71 ms
31,876 KB
testcase_16 AC 106 ms
40,348 KB
testcase_17 AC 123 ms
46,228 KB
testcase_18 AC 28 ms
27,144 KB
testcase_19 AC 28 ms
23,092 KB
testcase_20 AC 28 ms
27,260 KB
testcase_21 AC 27 ms
25,480 KB
testcase_22 AC 29 ms
27,220 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var ans = 0L;
        for (var b = 0; b < 28; ++b)
        {
            var count = 0L;
            var tmp = 0;
            for (var i = 0; i < a.Length; ++i)
            {
                if ((a[i] & (1 << b)) == 0) ++tmp;
                else tmp = 0;
                count += tmp;
            }
            ans += (1L << b) * ((long)n * (n + 1) / 2 - count);
        }
        WriteLine(ans);
    }
}
0