結果
問題 |
No.2939 Sigma Popcount Problem
|
ユーザー |
![]() |
提出日時 | 2024-10-19 11:50:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,780 ms / 2,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 333 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 255,872 KB |
最終ジャッジ日時 | 2024-12-27 00:26:32 |
合計ジャッジ時間 | 15,749 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from functools import lru_cache import pypyjit pypyjit.set_param('max_unroll_recursion=-1') two = [1] * 65 for i in range(64): two[i + 1] = two[i] * 2 @lru_cache(maxsize=None) def f(n): if n <= 0: return 0 now = 0 for i in range(1, 65): if two[i] - 1 > n: break now = two[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))