結果

問題 No.737 PopCount
ユーザー convexineqconvexineq
提出日時 2021-03-16 17:28:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 1,000 ms
コード長 281 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 56,740 KB
最終ジャッジ日時 2024-04-25 15:40:26
合計ジャッジ時間 1,558 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,692 KB
testcase_01 AC 39 ms
55,180 KB
testcase_02 AC 42 ms
56,160 KB
testcase_03 AC 41 ms
55,228 KB
testcase_04 AC 41 ms
55,392 KB
testcase_05 AC 40 ms
55,280 KB
testcase_06 AC 42 ms
56,392 KB
testcase_07 AC 40 ms
55,612 KB
testcase_08 AC 42 ms
56,168 KB
testcase_09 AC 40 ms
55,540 KB
testcase_10 AC 41 ms
55,640 KB
testcase_11 AC 42 ms
56,532 KB
testcase_12 AC 43 ms
56,740 KB
testcase_13 AC 40 ms
55,620 KB
testcase_14 AC 41 ms
56,336 KB
testcase_15 AC 39 ms
55,052 KB
testcase_16 AC 41 ms
55,232 KB
testcase_17 AC 41 ms
56,008 KB
権限があれば一括ダウンロードができます

ソースコード

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