結果

問題 No.854 公平なりんご分配
ユーザー H3PO4H3PO4
提出日時 2021-02-27 10:38:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,394 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,972 KB
実行使用メモリ 335,792 KB
最終ジャッジ日時 2024-04-10 15:22:02
合計ジャッジ時間 47,860 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
60,016 KB
testcase_01 AC 34 ms
52,992 KB
testcase_02 AC 36 ms
53,688 KB
testcase_03 AC 36 ms
53,468 KB
testcase_04 AC 35 ms
53,592 KB
testcase_05 AC 35 ms
52,908 KB
testcase_06 AC 34 ms
52,576 KB
testcase_07 AC 34 ms
52,868 KB
testcase_08 AC 34 ms
53,336 KB
testcase_09 AC 33 ms
53,972 KB
testcase_10 AC 33 ms
52,644 KB
testcase_11 AC 34 ms
53,340 KB
testcase_12 AC 39 ms
60,724 KB
testcase_13 AC 38 ms
60,872 KB
testcase_14 AC 37 ms
53,348 KB
testcase_15 AC 32 ms
53,268 KB
testcase_16 AC 38 ms
60,276 KB
testcase_17 AC 39 ms
60,116 KB
testcase_18 AC 39 ms
61,108 KB
testcase_19 AC 40 ms
61,252 KB
testcase_20 AC 40 ms
59,472 KB
testcase_21 AC 38 ms
60,212 KB
testcase_22 AC 74 ms
75,560 KB
testcase_23 AC 66 ms
72,048 KB
testcase_24 AC 91 ms
78,908 KB
testcase_25 AC 61 ms
69,368 KB
testcase_26 AC 96 ms
79,804 KB
testcase_27 AC 75 ms
74,276 KB
testcase_28 AC 76 ms
74,708 KB
testcase_29 AC 53 ms
66,984 KB
testcase_30 AC 62 ms
71,204 KB
testcase_31 AC 97 ms
79,372 KB
testcase_32 AC 447 ms
129,136 KB
testcase_33 AC 521 ms
105,728 KB
testcase_34 AC 844 ms
148,948 KB
testcase_35 AC 612 ms
133,856 KB
testcase_36 AC 232 ms
82,328 KB
testcase_37 AC 441 ms
125,608 KB
testcase_38 AC 400 ms
115,936 KB
testcase_39 AC 1,193 ms
155,176 KB
testcase_40 AC 442 ms
102,032 KB
testcase_41 AC 556 ms
122,876 KB
testcase_42 AC 728 ms
147,328 KB
testcase_43 AC 856 ms
126,472 KB
testcase_44 AC 860 ms
143,644 KB
testcase_45 AC 534 ms
93,348 KB
testcase_46 AC 1,158 ms
143,292 KB
testcase_47 AC 449 ms
112,936 KB
testcase_48 AC 684 ms
146,224 KB
testcase_49 AC 634 ms
147,436 KB
testcase_50 AC 365 ms
125,560 KB
testcase_51 AC 1,135 ms
146,480 KB
testcase_52 AC 524 ms
110,260 KB
testcase_53 AC 390 ms
107,560 KB
testcase_54 AC 567 ms
114,948 KB
testcase_55 AC 295 ms
106,732 KB
testcase_56 AC 303 ms
107,664 KB
testcase_57 AC 380 ms
103,340 KB
testcase_58 AC 445 ms
91,028 KB
testcase_59 AC 248 ms
99,236 KB
testcase_60 AC 409 ms
104,144 KB
testcase_61 AC 182 ms
83,080 KB
testcase_62 AC 435 ms
100,548 KB
testcase_63 AC 303 ms
101,920 KB
testcase_64 AC 200 ms
86,284 KB
testcase_65 AC 498 ms
138,840 KB
testcase_66 AC 310 ms
93,944 KB
testcase_67 AC 458 ms
119,016 KB
testcase_68 AC 381 ms
97,256 KB
testcase_69 AC 504 ms
153,912 KB
testcase_70 AC 274 ms
101,704 KB
testcase_71 AC 289 ms
104,188 KB
testcase_72 AC 277 ms
83,660 KB
testcase_73 AC 371 ms
127,164 KB
testcase_74 AC 628 ms
139,460 KB
testcase_75 AC 366 ms
105,340 KB
testcase_76 AC 481 ms
126,732 KB
testcase_77 AC 558 ms
146,848 KB
testcase_78 AC 513 ms
99,548 KB
testcase_79 AC 588 ms
120,564 KB
testcase_80 AC 592 ms
122,676 KB
testcase_81 AC 438 ms
123,780 KB
testcase_82 MLE -
testcase_83 MLE -
testcase_84 MLE -
testcase_85 AC 1,297 ms
227,628 KB
testcase_86 AC 168 ms
92,008 KB
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])


N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
queries = [tuple(map(int, input().split())) for _ in range(Q)]

MAX = max(max(A), 1)
P = tuple(primes(MAX))
L = len(P)
acc_list = [[0] * (N + 1) for _ in range(L)]

INF = 10 ** 7
for i, a in enumerate(A, 1):
    if a:
        temp = a
        for x, pr in enumerate(P):
            ct = 0
            while not temp % pr:
                temp //= pr
                ct += 1
            acc_list[x][i] += ct
    else:
        for p in range(L):
            acc_list[p][i] = INF
for p in range(L):
    for i in range(N):
        acc_list[p][i + 1] += acc_list[p][i]

for p, l, r in queries:
    temp = p
    for x, pr in enumerate(P):
        ct = 0
        while not temp % pr:
            temp //= pr
            ct += 1
        diff = acc_list[x][r] - acc_list[x][l - 1]
        if diff >= INF:
            print('Yes')
            break
        elif diff < ct:
            print('NO')
            break
    else:
        print('Yes' if temp == 1 else 'NO')
0