結果

問題 No.854 公平なりんご分配
ユーザー H3PO4H3PO4
提出日時 2021-02-27 10:55:46
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,421 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 296,980 KB
最終ジャッジ日時 2024-04-10 15:26:10
合計ジャッジ時間 48,843 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,404 KB
testcase_01 AC 38 ms
53,568 KB
testcase_02 AC 39 ms
53,496 KB
testcase_03 AC 38 ms
53,740 KB
testcase_04 AC 36 ms
53,952 KB
testcase_05 AC 36 ms
53,068 KB
testcase_06 AC 37 ms
54,524 KB
testcase_07 AC 36 ms
53,128 KB
testcase_08 AC 36 ms
53,984 KB
testcase_09 AC 36 ms
52,852 KB
testcase_10 AC 37 ms
53,004 KB
testcase_11 AC 35 ms
53,252 KB
testcase_12 AC 40 ms
61,068 KB
testcase_13 AC 41 ms
61,812 KB
testcase_14 AC 35 ms
53,728 KB
testcase_15 AC 36 ms
54,436 KB
testcase_16 AC 41 ms
60,640 KB
testcase_17 AC 43 ms
60,896 KB
testcase_18 AC 43 ms
60,636 KB
testcase_19 AC 41 ms
60,980 KB
testcase_20 AC 43 ms
61,220 KB
testcase_21 AC 42 ms
61,088 KB
testcase_22 AC 74 ms
74,488 KB
testcase_23 AC 73 ms
72,848 KB
testcase_24 AC 93 ms
78,716 KB
testcase_25 AC 66 ms
69,900 KB
testcase_26 AC 93 ms
78,448 KB
testcase_27 AC 78 ms
75,616 KB
testcase_28 AC 75 ms
73,880 KB
testcase_29 AC 56 ms
66,852 KB
testcase_30 AC 62 ms
69,804 KB
testcase_31 AC 95 ms
78,324 KB
testcase_32 AC 413 ms
155,744 KB
testcase_33 AC 357 ms
95,876 KB
testcase_34 AC 754 ms
189,176 KB
testcase_35 AC 550 ms
164,280 KB
testcase_36 AC 220 ms
84,028 KB
testcase_37 AC 402 ms
151,216 KB
testcase_38 AC 294 ms
99,132 KB
testcase_39 AC 1,156 ms
198,296 KB
testcase_40 AC 369 ms
94,492 KB
testcase_41 AC 544 ms
147,884 KB
testcase_42 AC 714 ms
186,360 KB
testcase_43 AC 762 ms
154,632 KB
testcase_44 AC 867 ms
180,636 KB
testcase_45 AC 475 ms
93,768 KB
testcase_46 AC 1,047 ms
180,800 KB
testcase_47 AC 380 ms
99,152 KB
testcase_48 AC 670 ms
184,568 KB
testcase_49 AC 599 ms
185,740 KB
testcase_50 AC 369 ms
150,220 KB
testcase_51 AC 1,054 ms
173,344 KB
testcase_52 AC 478 ms
102,064 KB
testcase_53 AC 330 ms
97,600 KB
testcase_54 AC 481 ms
104,436 KB
testcase_55 AC 261 ms
95,708 KB
testcase_56 AC 282 ms
95,492 KB
testcase_57 AC 317 ms
94,780 KB
testcase_58 AC 409 ms
92,284 KB
testcase_59 AC 246 ms
91,396 KB
testcase_60 AC 361 ms
96,748 KB
testcase_61 AC 175 ms
83,788 KB
testcase_62 AC 388 ms
96,108 KB
testcase_63 AC 295 ms
95,884 KB
testcase_64 AC 191 ms
84,124 KB
testcase_65 AC 530 ms
171,724 KB
testcase_66 AC 267 ms
89,928 KB
testcase_67 AC 422 ms
105,272 KB
testcase_68 AC 332 ms
95,476 KB
testcase_69 AC 473 ms
192,392 KB
testcase_70 AC 242 ms
92,968 KB
testcase_71 AC 258 ms
94,540 KB
testcase_72 AC 264 ms
85,936 KB
testcase_73 AC 381 ms
153,856 KB
testcase_74 AC 583 ms
174,848 KB
testcase_75 AC 334 ms
95,940 KB
testcase_76 AC 437 ms
154,552 KB
testcase_77 AC 529 ms
185,964 KB
testcase_78 AC 457 ms
97,452 KB
testcase_79 AC 527 ms
107,232 KB
testcase_80 AC 529 ms
148,892 KB
testcase_81 AC 417 ms
149,592 KB
testcase_82 AC 1,224 ms
296,492 KB
testcase_83 AC 1,904 ms
296,484 KB
testcase_84 AC 1,881 ms
296,212 KB
testcase_85 AC 1,235 ms
259,432 KB
testcase_86 AC 130 ms
105,564 KB
testcase_87 AC 1,243 ms
296,476 KB
testcase_88 AC 1,231 ms
296,728 KB
testcase_89 AC 1,245 ms
296,720 KB
testcase_90 AC 1,237 ms
296,908 KB
testcase_91 AC 1,241 ms
296,832 KB
testcase_92 TLE -
testcase_93 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from array import array

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 = [(map(int, input().split())) for _ in range(Q)]

MAX = max(max(A), 1)
P = tuple(primes(MAX))
L = len(P)
acc_list = [array('I', [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