結果

問題 No.737 PopCount
ユーザー convexineq
提出日時 2021-03-16 17:28:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 281 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 55,424 KB
最終ジャッジ日時 2024-11-08 02:46:13
合計ジャッジ時間 1,878 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=None)
def f(n):
    # 返り値: sum(x*ppopcnt(x)), sum(popcnt(x))
    if n==0: return 0,0
    (a,b),(c,d) = f(n//2),f((n-1)//2)
    x = (n+n%2)//2
    return 2*(a+c) + d + x*x, b + d + x

n = int(input())
print(f(n)[0]%(10**9+7))
0