結果

問題 No.854 公平なりんご分配
ユーザー H3PO4H3PO4
提出日時 2021-02-27 10:12:35
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,578 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 387,496 KB
最終ジャッジ日時 2024-04-10 15:19:17
合計ジャッジ時間 54,246 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 45 ms
61,240 KB
testcase_02 AC 39 ms
59,184 KB
testcase_03 AC 40 ms
61,612 KB
testcase_04 AC 38 ms
60,240 KB
testcase_05 AC 39 ms
59,920 KB
testcase_06 AC 38 ms
61,964 KB
testcase_07 AC 39 ms
60,708 KB
testcase_08 AC 39 ms
61,716 KB
testcase_09 AC 39 ms
60,752 KB
testcase_10 AC 40 ms
61,080 KB
testcase_11 AC 41 ms
61,600 KB
testcase_12 AC 44 ms
62,492 KB
testcase_13 AC 44 ms
61,928 KB
testcase_14 AC 37 ms
59,832 KB
testcase_15 AC 39 ms
62,144 KB
testcase_16 AC 44 ms
62,984 KB
testcase_17 AC 47 ms
63,252 KB
testcase_18 AC 41 ms
61,144 KB
testcase_19 AC 41 ms
62,164 KB
testcase_20 AC 42 ms
62,224 KB
testcase_21 AC 42 ms
61,336 KB
testcase_22 AC 67 ms
72,876 KB
testcase_23 AC 64 ms
71,816 KB
testcase_24 AC 94 ms
79,464 KB
testcase_25 AC 58 ms
69,308 KB
testcase_26 AC 95 ms
79,336 KB
testcase_27 AC 87 ms
79,588 KB
testcase_28 AC 69 ms
72,380 KB
testcase_29 AC 50 ms
65,580 KB
testcase_30 AC 58 ms
68,592 KB
testcase_31 AC 98 ms
79,416 KB
testcase_32 AC 341 ms
129,692 KB
testcase_33 AC 518 ms
105,544 KB
testcase_34 AC 900 ms
148,568 KB
testcase_35 AC 589 ms
134,136 KB
testcase_36 AC 295 ms
82,756 KB
testcase_37 AC 351 ms
126,136 KB
testcase_38 AC 282 ms
116,636 KB
testcase_39 AC 1,658 ms
154,916 KB
testcase_40 AC 589 ms
102,072 KB
testcase_41 AC 637 ms
123,224 KB
testcase_42 AC 736 ms
147,368 KB
testcase_43 AC 1,128 ms
125,916 KB
testcase_44 AC 1,105 ms
143,576 KB
testcase_45 AC 840 ms
93,360 KB
testcase_46 AC 1,568 ms
143,248 KB
testcase_47 AC 518 ms
112,964 KB
testcase_48 AC 670 ms
147,884 KB
testcase_49 AC 580 ms
149,256 KB
testcase_50 AC 297 ms
125,284 KB
testcase_51 AC 1,539 ms
146,560 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0