結果
問題 | No.854 公平なりんご分配 |
ユーザー | H3PO4 |
提出日時 | 2021-02-27 10:12:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,578 bytes |
コンパイル時間 | 319 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 333,968 KB |
最終ジャッジ日時 | 2024-10-02 17:07:29 |
合計ジャッジ時間 | 60,970 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
64,000 KB |
testcase_01 | AC | 45 ms
60,160 KB |
testcase_02 | AC | 43 ms
58,752 KB |
testcase_03 | AC | 47 ms
60,672 KB |
testcase_04 | AC | 43 ms
58,624 KB |
testcase_05 | AC | 45 ms
59,776 KB |
testcase_06 | AC | 46 ms
60,416 KB |
testcase_07 | AC | 45 ms
59,904 KB |
testcase_08 | AC | 44 ms
59,648 KB |
testcase_09 | AC | 47 ms
60,160 KB |
testcase_10 | AC | 46 ms
60,800 KB |
testcase_11 | AC | 48 ms
59,868 KB |
testcase_12 | AC | 49 ms
62,208 KB |
testcase_13 | AC | 50 ms
61,952 KB |
testcase_14 | AC | 44 ms
59,136 KB |
testcase_15 | AC | 46 ms
60,288 KB |
testcase_16 | AC | 49 ms
61,952 KB |
testcase_17 | AC | 49 ms
62,080 KB |
testcase_18 | AC | 48 ms
60,672 KB |
testcase_19 | AC | 48 ms
60,928 KB |
testcase_20 | AC | 46 ms
60,416 KB |
testcase_21 | AC | 48 ms
61,056 KB |
testcase_22 | AC | 76 ms
71,040 KB |
testcase_23 | AC | 76 ms
71,168 KB |
testcase_24 | AC | 111 ms
79,616 KB |
testcase_25 | AC | 67 ms
68,352 KB |
testcase_26 | AC | 113 ms
79,540 KB |
testcase_27 | AC | 101 ms
79,232 KB |
testcase_28 | AC | 75 ms
71,424 KB |
testcase_29 | AC | 56 ms
64,492 KB |
testcase_30 | AC | 68 ms
67,968 KB |
testcase_31 | AC | 117 ms
78,796 KB |
testcase_32 | AC | 357 ms
129,152 KB |
testcase_33 | AC | 630 ms
105,468 KB |
testcase_34 | AC | 943 ms
148,808 KB |
testcase_35 | AC | 667 ms
134,040 KB |
testcase_36 | AC | 319 ms
82,360 KB |
testcase_37 | AC | 371 ms
125,952 KB |
testcase_38 | AC | 288 ms
116,352 KB |
testcase_39 | AC | 1,687 ms
155,412 KB |
testcase_40 | AC | 782 ms
102,140 KB |
testcase_41 | AC | 706 ms
122,880 KB |
testcase_42 | AC | 773 ms
147,444 KB |
testcase_43 | AC | 1,226 ms
125,788 KB |
testcase_44 | AC | 1,175 ms
143,872 KB |
testcase_45 | AC | 1,155 ms
92,972 KB |
testcase_46 | AC | 1,644 ms
142,992 KB |
testcase_47 | AC | 554 ms
113,244 KB |
testcase_48 | AC | 690 ms
147,288 KB |
testcase_49 | AC | 594 ms
149,248 KB |
testcase_50 | AC | 311 ms
125,056 KB |
testcase_51 | AC | 1,586 ms
146,748 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | MLE | - |
testcase_83 | MLE | - |
testcase_84 | MLE | - |
testcase_85 | MLE | - |
testcase_86 | MLE | - |
testcase_87 | MLE | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
ソースコード
import sys input = sys.stdin.buffer.readline def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n ** 0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return (i for i in range(n + 1) if is_prime[i]) def factorization(n): arr = dict() temp = n for i in range(2, int(-(-n ** 0.5 // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr[i] = cnt if temp != 1: arr[temp] = 1 if not arr and n != 1: arr[n] = 1 return arr N = int(input()) A = tuple(map(int, input().split())) Q = int(input()) queries = [tuple(map(int, input().split())) for _ in range(Q)] P = tuple(primes(2000)) acc_list = [[0] * (N + 1) for _ in range(len(P))] p2i = {pr: i for i, pr in enumerate(P)} INF = 100 for i, a in enumerate(A, 1): if a: for k, v in factorization(a).items(): acc_list[p2i[k]][i] += v else: for p in range(len(P)): acc_list[p][i] = INF for p in range(len(P)): for i in range(N): acc_list[p][i + 1] += acc_list[p][i] for p, l, r in queries: temp = p for pr in P: ct = 0 while not temp % pr: temp //= pr ct += 1 if acc_list[p2i[pr]][r] - acc_list[p2i[pr]][l - 1] < ct: print('NO') break else: print('Yes' if temp == 1 else 'NO')