結果
問題 | No.1711 Divide LCM |
ユーザー | chineristAC |
提出日時 | 2021-08-13 04:05:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 596 ms / 4,000 ms |
コード長 | 1,223 bytes |
コンパイル時間 | 245 ms |
コンパイル使用メモリ | 82,700 KB |
実行使用メモリ | 188,184 KB |
最終ジャッジ日時 | 2024-09-17 17:01:41 |
合計ジャッジ時間 | 14,461 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,888 KB |
testcase_01 | AC | 41 ms
54,016 KB |
testcase_02 | AC | 42 ms
53,888 KB |
testcase_03 | AC | 74 ms
73,864 KB |
testcase_04 | AC | 93 ms
76,928 KB |
testcase_05 | AC | 117 ms
77,696 KB |
testcase_06 | AC | 106 ms
77,092 KB |
testcase_07 | AC | 113 ms
77,184 KB |
testcase_08 | AC | 101 ms
77,056 KB |
testcase_09 | AC | 138 ms
77,644 KB |
testcase_10 | AC | 97 ms
77,056 KB |
testcase_11 | AC | 164 ms
78,336 KB |
testcase_12 | AC | 100 ms
77,056 KB |
testcase_13 | AC | 58 ms
65,280 KB |
testcase_14 | AC | 85 ms
76,776 KB |
testcase_15 | AC | 93 ms
76,928 KB |
testcase_16 | AC | 59 ms
66,440 KB |
testcase_17 | AC | 87 ms
76,800 KB |
testcase_18 | AC | 399 ms
144,120 KB |
testcase_19 | AC | 398 ms
144,580 KB |
testcase_20 | AC | 420 ms
144,164 KB |
testcase_21 | AC | 276 ms
101,376 KB |
testcase_22 | AC | 596 ms
149,528 KB |
testcase_23 | AC | 570 ms
188,184 KB |
testcase_24 | AC | 274 ms
90,880 KB |
testcase_25 | AC | 273 ms
89,856 KB |
testcase_26 | AC | 258 ms
88,468 KB |
testcase_27 | AC | 267 ms
89,416 KB |
testcase_28 | AC | 267 ms
89,728 KB |
testcase_29 | AC | 82 ms
76,672 KB |
testcase_30 | AC | 285 ms
98,116 KB |
testcase_31 | AC | 84 ms
76,928 KB |
testcase_32 | AC | 297 ms
103,984 KB |
testcase_33 | AC | 282 ms
101,504 KB |
testcase_34 | AC | 97 ms
77,052 KB |
testcase_35 | AC | 293 ms
88,652 KB |
testcase_36 | AC | 308 ms
89,728 KB |
testcase_37 | AC | 296 ms
89,888 KB |
testcase_38 | AC | 288 ms
112,328 KB |
testcase_39 | AC | 303 ms
102,084 KB |
testcase_40 | AC | 82 ms
76,988 KB |
testcase_41 | AC | 83 ms
76,712 KB |
testcase_42 | AC | 83 ms
76,928 KB |
testcase_43 | AC | 84 ms
76,676 KB |
testcase_44 | AC | 78 ms
76,556 KB |
ソースコード
import sys from collections import deque input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) LCM = {} all_divisors = set() A = [1 for i in range(N)] for i in range(N): m = int(input()) D = [1] for _ in range(m): p,e = mi() t = pow(p,e) A[i] *= t D = [d for d in D] + [d*t for d in D] if p in LCM: LCM[p] = max(LCM[p],t) else: LCM[p] = t for d in D: all_divisors.add(d) prime_pow = [LCM[p] for p in LCM] n = len(prime_pow) deq = deque([(1,-1)]) prod = -1 while deq: v,k = deq.popleft() for i in range(k+1,n): if v * prime_pow[i] not in all_divisors: prod = v * prime_pow[i] deq = [] break deq.append((v*prime_pow[i],i)) if prod==-1: exit(print(-1)) selected_p = [] for i in range(n): if prod%prime_pow[i]==0: selected_p.append(prime_pow[i]) k = len(selected_p) S = [[] for i in range(k)] for a in A: for i in range(k): if a%selected_p[i]: S[i].append(a) break print(k) for i in range(k): S[i] = [len(S[i])] + S[i] print(*S[i])