結果
問題 | No.1611 Minimum Multiple with Double Divisors |
ユーザー | shotoyoo |
提出日時 | 2021-07-21 22:55:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,558 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 114,944 KB |
最終ジャッジ日時 | 2024-07-17 20:00:47 |
合計ジャッジ時間 | 22,264 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 953 ms
114,944 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 170 ms
101,888 KB |
testcase_29 | AC | 170 ms
101,888 KB |
testcase_30 | AC | 177 ms
102,204 KB |
testcase_31 | AC | 168 ms
102,408 KB |
testcase_32 | AC | 168 ms
102,188 KB |
testcase_33 | AC | 171 ms
102,144 KB |
testcase_34 | AC | 170 ms
102,528 KB |
testcase_35 | WA | - |
testcase_36 | AC | 173 ms
102,144 KB |
testcase_37 | AC | 167 ms
102,144 KB |
testcase_38 | AC | 170 ms
102,400 KB |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) def hurui(n): """線形篩 pl: 素数のリスト mpf: iを割り切る最小の素因数 """ pl = [] mpf = [None]*(n+1) for d in range(2,n+1): if mpf[d] is None: mpf[d] = d pl.append(d) for p in pl: if p*d>n or p>mpf[d]: break mpf[p*d] = p return pl, mpf from collections import defaultdict def factor(num): d = defaultdict(int) if num==1: d.update({1:1}) return d while num>1: d[mpf[num]] += 1 num //= mpf[num] return d def fs(num): f = factor(num) ans = [1] for k,v in f.items(): tmp = [] for i in range(len(ans)): val = 1 for _ in range(v): val *= k ans.append(ans[i]*val) return ans def sub(x,p): res = 0 while x%p==0: x //= p res += 1 return res inf = 10**15 from heapq import heappop as hpp, heappush as hp, heapify def dijkstra(start,d): n = len(d) vals = [inf] * n h = [(0, start)] # (距離, ノード番号) vals[start] = 0 # order = [] while h: val, u = hpp(h) if val>vals[u]: continue # order.append(u) for v in range(u+1,n): dd = d[u][v] # for d,v in ns[u]: if vals[v]>val+dd: vals[v] = val+dd hp(h, (vals[v], v)) return vals #, order pl, mpf = hurui(10**6) t = int(input()) ans = [] for i in range(t): x = int(input()) for p in pl: if x%p!=0: res = p break else: assert 0 m = 10 count = [-1]*m # 回数がiの素数の最小 for i in range(50)[::-1]: v = sub(x,pl[i]) if v<m: count[v] = pl[i] inf = 10**9 d = [[inf]*m for _ in range(m)] for i in range(m): v = count[i] if v==-1: continue cost = v for j in range(i+1,m): d[i][j] = cost cost *= v n = m for k in range(n): for i in range(k): for j in range(k+1,n): d[i][j] = min(d[i][j], d[i][k]+d[k][j]) for i in range(m): if 2*i+1<m: res = min(res, d[i][2*i+1]) ans.append(res*x) write("\n".join(map(str, ans)))