結果
問題 | No.1711 Divide LCM |
ユーザー | chineristAC |
提出日時 | 2021-08-07 14:43:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,073 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 67,352 KB |
最終ジャッジ日時 | 2024-09-17 17:00:17 |
合計ジャッジ時間 | 12,937 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 55 ms
65,280 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 | 56 ms
65,152 KB |
testcase_41 | AC | 55 ms
65,536 KB |
testcase_42 | AC | 57 ms
65,408 KB |
testcase_43 | AC | 55 ms
65,280 KB |
testcase_44 | AC | 54 ms
65,536 KB |
ソースコード
def eratosthenes(n): res=[0 for i in range(n+1)] prime=set([]) for i in range(2,n+1): if not res[i]: prime.add(i) for j in range(1,n//i+1): res[i*j]=1 return prime prime = eratosthenes(32000) def factorization(n): res = [] for p in prime: cnt = 0 while n%p==0: cnt += 1 n //= p if cnt: res.append((p,cnt)) if n!=1: res.append((n,1)) return res def divisors_prime(prime): res = [1] for p,cnt in prime: newres = [] for d in res: t = d for j in range(cnt+1): newres.append(t) t *= p res = newres return res import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) M = 10**9 N = int(input()) A = li() all_prime = {} all_divisors = set() for a in A: a_prime = factorization(a) for p,cnt in a_prime: if p not in all_prime: all_prime[p] = 0 all_prime[p] = max(all_prime[p],pow(p,cnt)) div = divisors_prime(a_prime) for d in div: all_divisors.add(d) P = [all_prime[p] for p in all_prime] P.sort() n = len(P) deq = deque([(1,-1)]) break_point = -1 while deq: v,k = deq.popleft() for i in range(k+1,n): tmp = v * P[i] if M < tmp or tmp not in all_divisors: break_point = tmp deq = [] break deq.append((tmp,i)) if break_point==-1: exit(print(-1)) selected_P = [] for i in range(n): if break_point%P[i]==0: selected_P.append(P[i]) k = len(selected_P) S = [[] for i in range(k)] for i in range(N): for j in range(k): if A[i]%selected_P[j]: S[j].append(A[i]) break print(k) for i in range(k): S[i] = [len(S[i])] + S[i] print(*S[i])