結果
問題 |
No.2939 Sigma Popcount Problem
|
ユーザー |
![]() |
提出日時 | 2024-10-19 11:48:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 513 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 255,820 KB |
最終ジャッジ日時 | 2024-10-19 11:48:59 |
合計ジャッジ時間 | 20,368 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 TLE * 4 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from functools import lru_cache import pypyjit pypyjit.set_param('max_unroll_recursion=-1') @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))