結果

問題 No.375 立方体のN等分 (1)
ユーザー ebicochinealebicochineal
提出日時 2016-06-16 18:21:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 939 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,004 KB
最終ジャッジ日時 2024-04-20 02:14:32
合計ジャッジ時間 2,050 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 31 ms
11,008 KB
testcase_03 AC 28 ms
10,880 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 28 ms
11,008 KB
testcase_06 AC 27 ms
11,008 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 28 ms
11,136 KB
testcase_09 AC 27 ms
10,880 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 26 ms
10,880 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 45 ms
12,800 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 29 ms
10,880 KB
testcase_17 AC 44 ms
12,672 KB
testcase_18 AC 46 ms
12,544 KB
testcase_19 AC 28 ms
10,880 KB
testcase_20 AC 26 ms
10,880 KB
testcase_21 AC 26 ms
11,008 KB
testcase_22 AC 73 ms
16,004 KB
testcase_23 AC 28 ms
10,880 KB
testcase_24 AC 26 ms
10,880 KB
testcase_25 AC 28 ms
11,136 KB
testcase_26 AC 46 ms
10,880 KB
testcase_27 AC 26 ms
10,880 KB
testcase_28 AC 43 ms
11,008 KB
testcase_29 AC 53 ms
10,880 KB
testcase_30 AC 45 ms
10,880 KB
testcase_31 AC 40 ms
10,880 KB
testcase_32 AC 53 ms
10,880 KB
testcase_33 AC 28 ms
10,880 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