結果
問題 | No.854 公平なりんご分配 |
ユーザー | H3PO4 |
提出日時 | 2021-02-27 10:25:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,669 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 81,856 KB |
実行使用メモリ | 330,228 KB |
最終ジャッジ日時 | 2024-10-02 17:07:57 |
合計ジャッジ時間 | 26,646 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
58,624 KB |
testcase_01 | AC | 47 ms
60,416 KB |
testcase_02 | AC | 45 ms
59,136 KB |
testcase_03 | AC | 47 ms
60,800 KB |
testcase_04 | AC | 45 ms
58,496 KB |
testcase_05 | AC | 47 ms
60,032 KB |
testcase_06 | AC | 47 ms
59,904 KB |
testcase_07 | AC | 47 ms
60,032 KB |
testcase_08 | AC | 47 ms
59,968 KB |
testcase_09 | AC | 46 ms
60,416 KB |
testcase_10 | AC | 46 ms
60,416 KB |
testcase_11 | AC | 47 ms
59,904 KB |
testcase_12 | AC | 51 ms
62,336 KB |
testcase_13 | AC | 52 ms
62,336 KB |
testcase_14 | AC | 43 ms
58,752 KB |
testcase_15 | AC | 47 ms
60,288 KB |
testcase_16 | AC | 51 ms
62,080 KB |
testcase_17 | AC | 52 ms
62,720 KB |
testcase_18 | AC | 49 ms
60,800 KB |
testcase_19 | AC | 49 ms
60,672 KB |
testcase_20 | AC | 48 ms
60,672 KB |
testcase_21 | AC | 49 ms
60,672 KB |
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 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
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 | MLE | - |
testcase_89 | MLE | - |
testcase_90 | MLE | - |
testcase_91 | MLE | - |
testcase_92 | MLE | - |
testcase_93 | MLE | - |
ソースコード
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 diff = acc_list[p2i[pr]][r] - acc_list[p2i[pr]][l - 1] if diff >= INF: print('Yes') break elif diff < ct: print('NO') break else: print('Yes' if temp == 1 else 'NO')