結果
問題 | No.1711 Divide LCM |
ユーザー | chineristAC |
提出日時 | 2021-08-05 22:05:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,402 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 100,172 KB |
最終ジャッジ日時 | 2024-09-17 16:58:36 |
合計ジャッジ時間 | 17,986 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 177 ms
99,552 KB |
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 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 181 ms
99,552 KB |
testcase_41 | AC | 187 ms
99,420 KB |
testcase_42 | AC | 180 ms
99,496 KB |
testcase_43 | AC | 180 ms
99,444 KB |
testcase_44 | AC | 185 ms
99,524 KB |
ソースコード
M = 10**6 spf = [i for i in range(M+1)] for i in range(2,M+1): if spf[i]==i: for j in range(2*i,M+1,i): spf[j] = i def factorization(n): assert 1<=n<=10**6 res = {} while n!=1: p = spf[n] res[p] = 0 while n%p==0: res[p] += 1 n //= p return res from collections import deque N = int(input()) A = list(map(int,input().split())) pre = [0 for i in range(M+1)] cnt = [0 for i in range(M+1)] for a in A: prime = factorization(a) for p in prime: pre[p] = max(pre[p],pow(p,prime[p])) cnt[a] += 1 P = [val for val in pre if val!=0] for i in range(1,M+1): for j in range(2*i,M+1,i): cnt[i] += cnt[j] n = len(P) deq = deque([(1,-1)]) break_point = -1 while deq: v,k = deq.popleft() for i in range(k+1,n): if M < v * P[i]: break_point = v * P[i] deq = [] break if not cnt[v*P[i]]: break_point = v * P[i] deq = [] break deq.append((v*P[i],i)) if break_point==-1: exit(print(-1)) k = 0 p = [] for i in range(n): if break_point%P[i]==0: p.append(P[i]) k += 1 S = [[] for i in range(k)] for a in A: for i in range(k): if a%p[i]: S[i].append(a) break print(k) for i in range(k): S[i] = [len(S[i])] + S[i] print(*S[i])