結果

問題 No.1737 One to N
ユーザー hiragnhiragn
提出日時 2022-11-03 01:36:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,575 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,596 KB
実行使用メモリ 19,808 KB
最終ジャッジ日時 2023-09-24 12:12:32
合計ジャッジ時間 18,716 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,537 ms
19,744 KB
testcase_01 AC 16 ms
8,008 KB
testcase_02 AC 209 ms
10,272 KB
testcase_03 AC 16 ms
8,012 KB
testcase_04 AC 111 ms
9,148 KB
testcase_05 AC 1,554 ms
19,808 KB
testcase_06 AC 1,575 ms
19,716 KB
testcase_07 AC 1,355 ms
18,924 KB
testcase_08 AC 110 ms
9,316 KB
testcase_09 AC 134 ms
9,572 KB
testcase_10 AC 524 ms
12,852 KB
testcase_11 AC 117 ms
9,284 KB
testcase_12 AC 322 ms
11,120 KB
testcase_13 AC 647 ms
13,740 KB
testcase_14 AC 996 ms
16,404 KB
testcase_15 AC 1,211 ms
17,448 KB
testcase_16 AC 386 ms
11,840 KB
testcase_17 AC 462 ms
12,584 KB
testcase_18 AC 468 ms
12,648 KB
testcase_19 AC 85 ms
8,952 KB
testcase_20 AC 94 ms
8,960 KB
testcase_21 AC 762 ms
14,756 KB
testcase_22 AC 98 ms
9,216 KB
testcase_23 AC 827 ms
15,096 KB
testcase_24 AC 631 ms
13,380 KB
testcase_25 AC 336 ms
11,328 KB
testcase_26 AC 165 ms
9,796 KB
testcase_27 AC 15 ms
7,904 KB
testcase_28 AC 529 ms
12,896 KB
testcase_29 AC 16 ms
7,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import inf


def main():
    n = int(input())
    dp = [inf] * (n + 1)
    dp[1] = 0
    for i in range(1, n + 1):
        for k in range(1, n // i + 1):
            dp[i * k] = min(dp[i] + k, dp[i * k])
    print(dp[n])


if __name__ == "__main__":
    main()
0