結果

問題 No.2300 Substring OR Sum
ユーザー LyricalMaestro
提出日時 2025-05-16 01:58:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 627 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 82,980 KB
実行使用メモリ 282,648 KB
最終ジャッジ日時 2025-05-16 01:58:45
合計ジャッジ時間 7,873 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2300


def main():
    N = int(input())
    A = list(map(int, input().split()))

    answer = 0
    for k in range(28):

        a_array = []
        for a in A:
            l = 1 if a & (1 << k) > 0 else 0
            a_array.append(l)
        
        a_str = "".join(map(str, a_array))
        l_array = a_str.split("1")
        y = 0
        for l in l_array:
            l_len = len(l)
            x = (l_len * (l_len + 1)) // 2
            y += x
        
        n2 = (N * (N + 1)) // 2

        n1 = n2 - y
        answer += n1 * (1 << k)
    print(answer)




if __name__ == '__main__':
    main()
0