結果

問題 No.376 立方体のN等分 (2)
ユーザー ebicochinealebicochineal
提出日時 2016-06-17 23:58:20
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 865 ms / 5,000 ms
コード長 939 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 11,088 KB
実行使用メモリ 62,248 KB
最終ジャッジ日時 2023-08-06 20:25:16
合計ジャッジ時間 9,391 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,232 KB
testcase_01 AC 15 ms
8,328 KB
testcase_02 AC 16 ms
8,324 KB
testcase_03 AC 18 ms
8,456 KB
testcase_04 AC 17 ms
8,268 KB
testcase_05 AC 16 ms
8,304 KB
testcase_06 AC 16 ms
8,208 KB
testcase_07 AC 16 ms
8,156 KB
testcase_08 AC 41 ms
8,220 KB
testcase_09 AC 16 ms
8,152 KB
testcase_10 AC 27 ms
9,500 KB
testcase_11 AC 54 ms
8,196 KB
testcase_12 AC 17 ms
8,156 KB
testcase_13 AC 17 ms
8,220 KB
testcase_14 AC 20 ms
8,220 KB
testcase_15 AC 76 ms
8,236 KB
testcase_16 AC 322 ms
36,260 KB
testcase_17 AC 16 ms
8,304 KB
testcase_18 AC 71 ms
8,232 KB
testcase_19 AC 18 ms
8,564 KB
testcase_20 AC 23 ms
8,300 KB
testcase_21 AC 387 ms
40,368 KB
testcase_22 AC 16 ms
7,948 KB
testcase_23 AC 506 ms
62,248 KB
testcase_24 AC 240 ms
35,220 KB
testcase_25 AC 16 ms
8,156 KB
testcase_26 AC 416 ms
42,652 KB
testcase_27 AC 613 ms
8,152 KB
testcase_28 AC 20 ms
8,296 KB
testcase_29 AC 25 ms
8,204 KB
testcase_30 AC 17 ms
8,152 KB
testcase_31 AC 185 ms
8,236 KB
testcase_32 AC 615 ms
8,308 KB
testcase_33 AC 865 ms
8,204 KB
testcase_34 AC 440 ms
8,236 KB
testcase_35 AC 439 ms
7,820 KB
testcase_36 AC 860 ms
8,196 KB
testcase_37 AC 864 ms
8,372 KB
testcase_38 AC 238 ms
8,332 KB
testcase_39 AC 15 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

def e(a, b, c, i):
    global tmin
    t = tuple(sorted([a,b,c]))
    if t in m:
        return
    else:
        m.add(t)
    s = sum((a, b, c))
    if i < 0:
        if s < tmin : tmin = s
        return
    if s > tmin : return
    j = i - 1
    e(a*p[i], b, c, j)
    e(a, b*p[i], c, j)
    e(a, b, c*p[i], j)

m = set()
tmin = 0
N = int(input())
p = f(N)
if len(p) > 3:
    tmin = N - 1
    b = 1
    while b:
        b = 0
        l = []
        for i in set(p):
            if p.count(i) > 3:
                l += [i]*(p.count(i)-2) + [i*i]
                b = 1
            else:
                l += [i]*(p.count(i))
        p = l
    e(1, 1, 1, len(p)-1)
    print(tmin-3, N-1)
else:
    print(sum(p)-len(p), N-1)
0