結果
問題 |
No.555 世界史のレポート
|
ユーザー |
![]() |
提出日時 | 2020-03-17 02:27:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 295 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-29 01:25:29 |
合計ジャッジ時間 | 1,789 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#!/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))