結果

問題 No.2300 Substring OR Sum
ユーザー ああいい
提出日時 2023-05-12 22:16:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 107,392 KB
最終ジャッジ日時 2024-11-28 18:45:31
合計ジャッジ時間 3,666 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

A = list(map(int,input().split()))

ans = 0
for i in range(28):
    tmp = 0
    j = 0
    while j < N:
        if A[j] >> i & 1 == 0:
            count = 1
            j += 1
            while j < N  and A[j] >> i & 1 == 0:
                j += 1
                count += 1
            tmp += count * (count + 1) // 2
        else:
            j += 1
    ans += (N * (N + 1) // 2 - tmp) * (1 << i)
print(ans)
            
0