結果

問題 No.737 PopCount
ユーザー convexineqconvexineq
提出日時 2021-03-16 17:22:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 1,000 ms
コード長 301 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 57,476 KB
最終ジャッジ日時 2024-04-25 15:35:55
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,360 KB
testcase_01 AC 43 ms
55,048 KB
testcase_02 AC 45 ms
55,776 KB
testcase_03 AC 43 ms
56,536 KB
testcase_04 AC 43 ms
55,708 KB
testcase_05 AC 45 ms
55,692 KB
testcase_06 AC 44 ms
56,872 KB
testcase_07 AC 45 ms
56,536 KB
testcase_08 AC 45 ms
57,476 KB
testcase_09 AC 45 ms
55,824 KB
testcase_10 AC 43 ms
54,792 KB
testcase_11 AC 42 ms
55,640 KB
testcase_12 AC 45 ms
55,868 KB
testcase_13 AC 43 ms
56,256 KB
testcase_14 AC 44 ms
56,400 KB
testcase_15 AC 43 ms
55,664 KB
testcase_16 AC 44 ms
55,784 KB
testcase_17 AC 45 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=None)
def f(n):
    if n==0: return 0
    return 2*f(n//2) + 2*f((n-1)//2) + g((n-1)//2) + ((n+n%2)//2)**2

@lru_cache(maxsize=None)
def g(n):
    if n==0: return 0
    return g(n//2) + g((n-1)//2) + (n+n%2)//2

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