結果

問題 No.555 世界史のレポート
ユーザー maspymaspy
提出日時 2020-03-17 02:27:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 8,976 KB
最終ジャッジ日時 2023-08-19 09:59:05
合計ジャッジ時間 2,130 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,796 KB
testcase_01 AC 19 ms
8,820 KB
testcase_02 AC 18 ms
8,908 KB
testcase_03 AC 18 ms
8,908 KB
testcase_04 AC 16 ms
8,944 KB
testcase_05 AC 17 ms
8,848 KB
testcase_06 AC 16 ms
8,892 KB
testcase_07 AC 16 ms
8,808 KB
testcase_08 AC 16 ms
8,848 KB
testcase_09 AC 17 ms
8,896 KB
testcase_10 AC 20 ms
8,884 KB
testcase_11 AC 20 ms
8,888 KB
testcase_12 AC 20 ms
8,976 KB
testcase_13 AC 20 ms
8,816 KB
testcase_14 AC 20 ms
8,880 KB
testcase_15 AC 24 ms
8,884 KB
testcase_16 AC 20 ms
8,840 KB
testcase_17 AC 20 ms
8,840 KB
testcase_18 AC 20 ms
8,892 KB
testcase_19 AC 20 ms
8,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import lru_cache

# %%
N, C, V = map(int, read().split())


# %%
@lru_cache(None)
def f(N):
    # N倍するためのコスト
    if N == 1:
        return 0
    sqN = int(N ** .5)
    ret = 10 ** 9
    for i in range(2, N + 1):
        j = (N+i-1) // i
        if j <= sqN:
            break
        x = C + (i - 1) * V + f(j)
        if ret > x:
            ret = x
    for j in range(1, sqN + 1):
        i = (N + j - 1) // j
        x = C + (i - 1) * V + f(j)
        if ret > x:
            ret = x
    return ret


# %%
print(f(N))
0