結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
![]() |
提出日時 | 2016-06-16 17:00:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 333 ms / 5,000 ms |
コード長 | 1,257 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-11 21:07:12 |
合計ジャッジ時間 | 3,287 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
def f(n): l = [] c = 2 a = 0 while c * c <= n: if n % c == 0: n //= c l += [c] else: c += 1 + a a = 1 if n > 1 : l += [n] return l def e1(a, b, c, i): global tmin s = sum((a, b, c)) if i < 0: if s < tmin : tmin = s return if s > tmin : return j = i-1 e2(a*l[i], b, c, j) def e2(a, b, c, i): global tmin s = sum((a, b, c)) if i < 0: if s < tmin : tmin = s return if s > tmin : return j = i-1 e2(a*l[i], b, c, j) e3(a, b*l[i], c, j) def e3(a, b, c, i): global tmin s = sum((a, b, c)) if i < 0: if s < tmin : tmin = s return if s > tmin : return j = i-1 e3(a*l[i], b, c, j) e3(a, b*l[i], c, j) e3(a, b, c*l[i], j) 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) l += [i*i] b = 1 else: l += [i]*(p.count(i)) p = l e1(1, 1, 1, len(p)-1) print(tmin-3, N-1) else: print(sum(p)-len(p), N-1)