結果
問題 |
No.2939 Sigma Popcount Problem
|
ユーザー |
![]() |
提出日時 | 2024-10-19 11:46:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 453 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 49,640 KB |
最終ジャッジ日時 | 2024-10-19 11:46:40 |
合計ジャッジ時間 | 4,760 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 12 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from functools import lru_cache @lru_cache(maxsize=None) def f(n): if n <= 0: return 0 now = 0 for i in range(1, 65): if 2 ** i - 1 > n: break now = 2 ** i - 1 r = n - now return f(now // 2) * 2 + (now + 1) // 2 + f(r - 1) + r T = int(input()) for _ in range(T): N = int(input()) print(f(N))