結果

問題 No.375 立方体のN等分 (1)
ユーザー Coki628Coki628
提出日時 2020-09-23 18:36:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,500 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,544 KB
実行使用メモリ 163,620 KB
最終ジャッジ日時 2023-09-10 08:28:07
合計ジャッジ時間 8,771 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
163,620 KB
testcase_01 AC 92 ms
71,892 KB
testcase_02 AC 120 ms
77,676 KB
testcase_03 AC 93 ms
72,056 KB
testcase_04 AC 92 ms
72,176 KB
testcase_05 AC 90 ms
71,868 KB
testcase_06 AC 99 ms
76,996 KB
testcase_07 AC 97 ms
77,020 KB
testcase_08 AC 122 ms
77,656 KB
testcase_09 AC 98 ms
76,880 KB
testcase_10 AC 101 ms
77,056 KB
testcase_11 AC 100 ms
77,292 KB
testcase_12 AC 99 ms
76,976 KB
testcase_13 AC 99 ms
77,156 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
EPS = 10**-10

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    for i in range(2, int(sqrt(num))+1):
        while num % i == 0:
            num //= i
            d[i] += 1
        if num == 1:
            break
    if num != 1:
        d[num] += 1
    return d

N = INT()

fact = factorize(N)
A = []
for k, v in fact.items():
    A += [k] * v
A.sort(reverse=1)
M = len(A)

memo = {}
def rec(x, y, z, i):
    if i == M:
        return x + y + z - 3
    # if (x, y, z, i) in memo:
    #     return memo[(x, y, z, i)]
    res = min(
        rec(x*A[i], y, z, i+1),
        rec(x, y*A[i], z, i+1),
        rec(x, y, z*A[i], i+1),
    )
    # memo[(x, y, z, i)] = res
    return res

mn = rec(1, 1, 1, 0)
print(mn, N-1)
0