結果
| 問題 |
No.1737 One to N
|
| コンテスト | |
| ユーザー |
wgrape
|
| 提出日時 | 2024-10-08 17:22:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 597 bytes |
| コンパイル時間 | 469 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 67,344 KB |
| 最終ジャッジ日時 | 2024-10-08 17:23:02 |
| 合計ジャッジ時間 | 3,151 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
def make_divisors(n):
lower_divisors , upper_divisors = [], []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n//i)
i += 1
return lower_divisors + upper_divisors[::-1]
N = int(input())
from functools import lru_cache
@lru_cache(maxsize=1000)
def f(x):
if x == 1:
return 0
divs = make_divisors(x)
best = 1 << 60
for d in divs:
if d == 1:
continue
best = min(best, f(x // d) + d)
return best
print(f(N))
wgrape