結果

問題 No.2939 Sigma Popcount Problem
ユーザー miya145592
提出日時 2024-10-18 21:32:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 82,780 KB
実行使用メモリ 77,076 KB
最終ジャッジ日時 2024-10-18 22:17:21
合計ジャッジ時間 4,265 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
T = int(input())
N = [int(input()) for _ in range(T)]
for n in N:
    n += 1
    ans = 0
    i = 0
    while True:
        cnt = n//(1<<(i+1))
        amari = n%(1<<(i+1))
        ans += cnt*(1<<i)
        if amari-(1<<i)>0:
            ans += amari-(1<<i)
        i+=1
        if cnt==0:
            break
    print(ans)
0