結果

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

ソースコード

diff #

for _ in range(int(input())):
  N = int(input())
  ans = 0
  s = 0
  for j in range(40,0,-1):
    if (N >> j) & 1:
      c = 1 << (j - 1)
      ans += (2 * s + j) * c
      s += 1
  if N % 2:
    ans += s
  s += N % 2
  print(ans + s)
0