結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 39 ms
52,480 KB
testcase_02 AC 39 ms
52,992 KB
testcase_03 AC 39 ms
53,120 KB
testcase_04 AC 38 ms
52,992 KB
testcase_05 AC 39 ms
52,992 KB
testcase_06 AC 39 ms
52,736 KB
testcase_07 AC 40 ms
52,736 KB
testcase_08 AC 41 ms
52,608 KB
testcase_09 AC 41 ms
52,992 KB
testcase_10 AC 42 ms
52,480 KB
testcase_11 AC 42 ms
52,352 KB
testcase_12 AC 47 ms
59,520 KB
testcase_13 AC 45 ms
59,776 KB
testcase_14 AC 37 ms
52,352 KB
testcase_15 AC 38 ms
53,248 KB
testcase_16 AC 44 ms
59,776 KB
testcase_17 AC 43 ms
59,904 KB
testcase_18 AC 43 ms
59,776 KB
testcase_19 AC 44 ms
59,776 KB
testcase_20 AC 43 ms
59,392 KB
testcase_21 AC 44 ms
59,904 KB
testcase_22 AC 75 ms
72,704 KB
testcase_23 AC 72 ms
70,016 KB
testcase_24 AC 106 ms
79,456 KB
testcase_25 AC 71 ms
67,968 KB
testcase_26 AC 113 ms
79,516 KB
testcase_27 AC 89 ms
72,448 KB
testcase_28 AC 83 ms
72,960 KB
testcase_29 AC 64 ms
65,408 KB
testcase_30 AC 72 ms
68,096 KB
testcase_31 AC 112 ms
79,232 KB
testcase_32 AC 485 ms
128,928 KB
testcase_33 AC 558 ms
103,212 KB
testcase_34 AC 913 ms
149,076 KB
testcase_35 AC 650 ms
134,076 KB
testcase_36 AC 288 ms
82,604 KB
testcase_37 AC 472 ms
126,208 KB
testcase_38 AC 380 ms
116,036 KB
testcase_39 AC 1,343 ms
155,376 KB
testcase_40 AC 621 ms
101,556 KB
testcase_41 AC 638 ms
123,388 KB
testcase_42 AC 817 ms
147,780 KB
testcase_43 AC 997 ms
126,240 KB
testcase_44 AC 992 ms
143,432 KB
testcase_45 AC 911 ms
93,192 KB
testcase_46 AC 1,332 ms
143,256 KB
testcase_47 AC 527 ms
113,448 KB
testcase_48 AC 764 ms
147,996 KB
testcase_49 AC 698 ms
149,056 KB
testcase_50 AC 406 ms
125,224 KB
testcase_51 AC 1,317 ms
146,248 KB
testcase_52 AC 718 ms
110,280 KB
testcase_53 AC 434 ms
107,752 KB
testcase_54 AC 726 ms
114,836 KB
testcase_55 AC 329 ms
106,772 KB
testcase_56 AC 348 ms
108,300 KB
testcase_57 AC 467 ms
102,996 KB
testcase_58 AC 670 ms
90,600 KB
testcase_59 AC 311 ms
99,352 KB
testcase_60 AC 547 ms
103,552 KB
testcase_61 AC 216 ms
83,256 KB
testcase_62 AC 620 ms
100,272 KB
testcase_63 AC 389 ms
101,240 KB
testcase_64 AC 278 ms
85,784 KB
testcase_65 AC 563 ms
139,776 KB
testcase_66 AC 407 ms
94,384 KB
testcase_67 AC 552 ms
118,624 KB
testcase_68 AC 528 ms
97,056 KB
testcase_69 AC 525 ms
153,764 KB
testcase_70 AC 288 ms
101,860 KB
testcase_71 AC 303 ms
104,616 KB
testcase_72 AC 287 ms
83,372 KB
testcase_73 AC 389 ms
127,540 KB
testcase_74 AC 654 ms
140,064 KB
testcase_75 AC 358 ms
104,756 KB
testcase_76 AC 451 ms
126,596 KB
testcase_77 AC 540 ms
146,852 KB
testcase_78 AC 529 ms
99,508 KB
testcase_79 AC 613 ms
120,276 KB
testcase_80 AC 657 ms
121,944 KB
testcase_81 AC 474 ms
123,416 KB
testcase_82 MLE -
testcase_83 MLE -
testcase_84 MLE -
testcase_85 AC 1,406 ms
227,668 KB
testcase_86 AC 132 ms
91,820 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