結果

問題 No.2939 Sigma Popcount Problem
ユーザー titia
提出日時 2024-10-18 22:00:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 76,248 KB
最終ジャッジ日時 2024-10-18 22:43:56
合計ジャッジ時間 4,693 ms
ジャッジサーバーID
(参考情報)
judge6 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    N=int(input())+1

    P=1
    ANS=0

    for i in range(1,51):
        P*=2

        ANS+=N//P * (P//2)

        rest=N%P

        ANS+=max(rest-P//2,0)

    print(ANS)
0