結果

問題 No.376 立方体のN等分 (2)
ユーザー 👑 rin204rin204
提出日時 2022-03-23 16:29:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,230 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 106,592 KB
最終ジャッジ日時 2024-04-20 00:28:48
合計ジャッジ時間 19,624 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,288 KB
testcase_01 AC 33 ms
52,808 KB
testcase_02 AC 139 ms
61,928 KB
testcase_03 AC 141 ms
63,092 KB
testcase_04 AC 156 ms
60,564 KB
testcase_05 AC 32 ms
53,716 KB
testcase_06 AC 32 ms
53,084 KB
testcase_07 AC 31 ms
52,480 KB
testcase_08 AC 39 ms
57,648 KB
testcase_09 AC 62 ms
58,316 KB
testcase_10 AC 278 ms
76,148 KB
testcase_11 AC 86 ms
58,968 KB
testcase_12 AC 110 ms
60,500 KB
testcase_13 AC 108 ms
58,760 KB
testcase_14 AC 115 ms
58,760 KB
testcase_15 AC 122 ms
58,080 KB
testcase_16 AC 2,362 ms
77,876 KB
testcase_17 AC 140 ms
58,952 KB
testcase_18 AC 143 ms
59,112 KB
testcase_19 AC 147 ms
62,252 KB
testcase_20 AC 144 ms
58,248 KB
testcase_21 AC 3,109 ms
77,796 KB
testcase_22 AC 149 ms
58,036 KB
testcase_23 AC 3,230 ms
77,708 KB
testcase_24 AC 2,370 ms
77,656 KB
testcase_25 AC 154 ms
58,380 KB
testcase_26 AC 2,717 ms
106,592 KB
testcase_27 AC 151 ms
58,736 KB
testcase_28 AC 152 ms
58,240 KB
testcase_29 AC 152 ms
58,844 KB
testcase_30 AC 152 ms
58,308 KB
testcase_31 AC 155 ms
58,976 KB
testcase_32 AC 157 ms
58,328 KB
testcase_33 AC 150 ms
57,788 KB
testcase_34 AC 156 ms
58,576 KB
testcase_35 AC 151 ms
57,772 KB
testcase_36 AC 154 ms
57,968 KB
testcase_37 AC 155 ms
58,176 KB
testcase_38 AC 156 ms
58,552 KB
testcase_39 AC 155 ms
59,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
divs = []

for i in range(1, int(n ** 0.5 + 1)):
    if n % i == 0:
        divs.append(i)
        if i != n // i:
            divs.append(n // i)
divs.sort()
l = len(divs)
double = [0] * l
for i, d in enumerate(divs):
    double[i] = d - 1
    for j, d2 in enumerate(divs[:i]):
        if d % d2 == 0:
            double[i] = min(double[i], d2 + d // d2 - 2)

ans = n - 1
dic = {d:i for i, d in enumerate(divs)}
for d in divs:
    ans = min(ans, d - 1 + double[dic[n // d]])
print(ans, n - 1)    
0