結果

問題 No.854 公平なりんご分配
ユーザー H3PO4H3PO4
提出日時 2021-02-27 10:28:07
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,673 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 335,636 KB
最終ジャッジ日時 2024-04-10 15:20:56
合計ジャッジ時間 56,846 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
65,824 KB
testcase_01 AC 44 ms
60,672 KB
testcase_02 AC 45 ms
59,520 KB
testcase_03 AC 47 ms
60,928 KB
testcase_04 AC 44 ms
58,752 KB
testcase_05 AC 46 ms
59,776 KB
testcase_06 AC 46 ms
60,032 KB
testcase_07 AC 46 ms
60,160 KB
testcase_08 AC 46 ms
60,032 KB
testcase_09 AC 51 ms
60,672 KB
testcase_10 AC 46 ms
60,288 KB
testcase_11 AC 46 ms
60,160 KB
testcase_12 AC 50 ms
62,464 KB
testcase_13 AC 51 ms
62,720 KB
testcase_14 AC 44 ms
59,008 KB
testcase_15 AC 45 ms
60,416 KB
testcase_16 AC 49 ms
62,080 KB
testcase_17 AC 48 ms
62,592 KB
testcase_18 AC 47 ms
61,184 KB
testcase_19 AC 49 ms
60,672 KB
testcase_20 AC 46 ms
60,928 KB
testcase_21 AC 47 ms
60,544 KB
testcase_22 AC 87 ms
73,868 KB
testcase_23 AC 79 ms
72,832 KB
testcase_24 AC 118 ms
79,468 KB
testcase_25 AC 72 ms
69,120 KB
testcase_26 AC 122 ms
79,872 KB
testcase_27 AC 111 ms
79,616 KB
testcase_28 AC 94 ms
73,600 KB
testcase_29 AC 58 ms
65,536 KB
testcase_30 AC 69 ms
69,248 KB
testcase_31 AC 122 ms
79,168 KB
testcase_32 AC 399 ms
128,600 KB
testcase_33 AC 705 ms
105,960 KB
testcase_34 AC 1,026 ms
149,552 KB
testcase_35 AC 699 ms
134,016 KB
testcase_36 AC 373 ms
82,860 KB
testcase_37 AC 406 ms
125,568 KB
testcase_38 AC 322 ms
116,468 KB
testcase_39 AC 1,827 ms
155,520 KB
testcase_40 AC 840 ms
102,952 KB
testcase_41 AC 766 ms
122,624 KB
testcase_42 AC 843 ms
147,140 KB
testcase_43 AC 1,326 ms
126,592 KB
testcase_44 AC 1,280 ms
143,360 KB
testcase_45 AC 1,416 ms
93,824 KB
testcase_46 AC 1,770 ms
143,472 KB
testcase_47 AC 611 ms
113,408 KB
testcase_48 AC 761 ms
146,540 KB
testcase_49 AC 658 ms
147,372 KB
testcase_50 AC 335 ms
126,048 KB
testcase_51 AC 1,745 ms
147,200 KB
testcase_52 AC 958 ms
110,384 KB
testcase_53 AC 494 ms
107,996 KB
testcase_54 AC 992 ms
115,236 KB
testcase_55 AC 309 ms
106,824 KB
testcase_56 AC 305 ms
108,288 KB
testcase_57 AC 587 ms
103,040 KB
testcase_58 AC 1,119 ms
90,940 KB
testcase_59 AC 288 ms
99,684 KB
testcase_60 AC 705 ms
104,320 KB
testcase_61 AC 287 ms
83,908 KB
testcase_62 AC 901 ms
100,544 KB
testcase_63 AC 455 ms
101,404 KB
testcase_64 AC 322 ms
86,656 KB
testcase_65 AC 454 ms
139,240 KB
testcase_66 AC 540 ms
95,164 KB
testcase_67 AC 630 ms
119,156 KB
testcase_68 AC 735 ms
98,100 KB
testcase_69 AC 328 ms
153,976 KB
testcase_70 AC 282 ms
102,064 KB
testcase_71 AC 311 ms
104,796 KB
testcase_72 AC 499 ms
83,816 KB
testcase_73 AC 331 ms
127,272 KB
testcase_74 AC 750 ms
139,992 KB
testcase_75 AC 547 ms
105,216 KB
testcase_76 AC 500 ms
127,156 KB
testcase_77 AC 509 ms
147,712 KB
testcase_78 AC 1,174 ms
100,096 KB
testcase_79 AC 808 ms
120,884 KB
testcase_80 AC 762 ms
122,752 KB
testcase_81 AC 452 ms
123,964 KB
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = 10 ** 7
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')
0