結果

問題 No.2939 Sigma Popcount Problem
ユーザー lif4635
提出日時 2024-10-18 21:28:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 76,784 KB
最終ジャッジ日時 2024-10-18 22:04:14
合計ジャッジ時間 5,061 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

def II() -> int : return int(input())
def MI() -> int : return map(int, input().split())
def TI() -> tuple[int] : return tuple(MI())
def LI() -> list[int] : return list(MI())
class fenwick_tree():
    n=1
    data=[0 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.data=[0 for i in range(N)]
    def add(self,p,x):
        assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n)
        p+=1
        while(p<=self.n):
            self.data[p-1]+=x
            p+=p& -p
    def sum(self,l,r):
        assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n)
        return self.sum0(r)-self.sum0(l)
    def sum0(self,r):
        s=0
        while(r>0):
            s+=self.data[r-1]
            r-=r&-r
        return s

t = II()

for _ in range(t):
    n = II() + 1
    ans = 0
    for i in range(30):
        s = 1<<i
        if n>>i & 1: #立っているとき
            ans += (n//(s*2)) * s
            ans += n%s 
        else:
            ans += (n//(s*2)) * s
    
    print(ans)
0