結果

問題 No.854 公平なりんご分配
ユーザー H3PO4H3PO4
提出日時 2021-02-27 11:03:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,430 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 297,796 KB
最終ジャッジ日時 2024-04-10 15:27:27
合計ジャッジ時間 44,824 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
54,308 KB
testcase_01 AC 35 ms
52,984 KB
testcase_02 AC 34 ms
53,208 KB
testcase_03 AC 34 ms
53,252 KB
testcase_04 AC 35 ms
53,276 KB
testcase_05 AC 33 ms
53,740 KB
testcase_06 AC 33 ms
53,220 KB
testcase_07 AC 33 ms
52,960 KB
testcase_08 AC 32 ms
53,280 KB
testcase_09 AC 31 ms
53,852 KB
testcase_10 AC 31 ms
53,708 KB
testcase_11 AC 32 ms
53,524 KB
testcase_12 AC 39 ms
61,392 KB
testcase_13 AC 42 ms
60,620 KB
testcase_14 AC 32 ms
53,072 KB
testcase_15 AC 33 ms
53,448 KB
testcase_16 AC 38 ms
60,764 KB
testcase_17 AC 38 ms
61,604 KB
testcase_18 AC 37 ms
60,588 KB
testcase_19 AC 39 ms
60,736 KB
testcase_20 AC 38 ms
62,340 KB
testcase_21 AC 39 ms
61,480 KB
testcase_22 AC 63 ms
72,300 KB
testcase_23 AC 63 ms
72,152 KB
testcase_24 AC 79 ms
76,324 KB
testcase_25 AC 60 ms
71,128 KB
testcase_26 AC 78 ms
76,744 KB
testcase_27 AC 69 ms
73,400 KB
testcase_28 AC 63 ms
71,604 KB
testcase_29 AC 52 ms
67,088 KB
testcase_30 AC 64 ms
70,604 KB
testcase_31 AC 81 ms
76,732 KB
testcase_32 AC 386 ms
155,332 KB
testcase_33 AC 333 ms
95,964 KB
testcase_34 AC 689 ms
187,400 KB
testcase_35 AC 541 ms
163,668 KB
testcase_36 AC 219 ms
84,212 KB
testcase_37 AC 400 ms
151,164 KB
testcase_38 AC 282 ms
99,036 KB
testcase_39 AC 1,030 ms
198,132 KB
testcase_40 AC 358 ms
94,996 KB
testcase_41 AC 472 ms
148,052 KB
testcase_42 AC 638 ms
185,296 KB
testcase_43 AC 641 ms
154,332 KB
testcase_44 AC 721 ms
179,316 KB
testcase_45 AC 434 ms
93,948 KB
testcase_46 AC 958 ms
181,212 KB
testcase_47 AC 364 ms
98,924 KB
testcase_48 AC 593 ms
182,968 KB
testcase_49 AC 566 ms
184,816 KB
testcase_50 AC 360 ms
149,572 KB
testcase_51 AC 916 ms
185,548 KB
testcase_52 AC 430 ms
102,532 KB
testcase_53 AC 308 ms
97,508 KB
testcase_54 AC 444 ms
104,536 KB
testcase_55 AC 251 ms
95,484 KB
testcase_56 AC 252 ms
95,048 KB
testcase_57 AC 300 ms
94,660 KB
testcase_58 AC 383 ms
92,776 KB
testcase_59 AC 220 ms
90,896 KB
testcase_60 AC 334 ms
96,560 KB
testcase_61 AC 174 ms
84,012 KB
testcase_62 AC 361 ms
95,788 KB
testcase_63 AC 269 ms
95,976 KB
testcase_64 AC 180 ms
84,364 KB
testcase_65 AC 466 ms
171,040 KB
testcase_66 AC 256 ms
90,844 KB
testcase_67 AC 395 ms
105,104 KB
testcase_68 AC 316 ms
95,616 KB
testcase_69 AC 435 ms
190,648 KB
testcase_70 AC 236 ms
92,580 KB
testcase_71 AC 245 ms
94,536 KB
testcase_72 AC 253 ms
86,040 KB
testcase_73 AC 364 ms
153,612 KB
testcase_74 AC 529 ms
174,180 KB
testcase_75 AC 307 ms
95,876 KB
testcase_76 AC 423 ms
153,908 KB
testcase_77 AC 499 ms
184,664 KB
testcase_78 AC 415 ms
97,472 KB
testcase_79 AC 463 ms
107,448 KB
testcase_80 AC 482 ms
148,320 KB
testcase_81 AC 383 ms
149,356 KB
testcase_82 AC 1,130 ms
297,420 KB
testcase_83 AC 1,742 ms
297,796 KB
testcase_84 AC 1,690 ms
297,164 KB
testcase_85 AC 1,130 ms
257,556 KB
testcase_86 AC 128 ms
104,160 KB
testcase_87 AC 1,159 ms
297,124 KB
testcase_88 AC 1,142 ms
297,256 KB
testcase_89 AC 1,132 ms
297,380 KB
testcase_90 AC 1,132 ms
297,364 KB
testcase_91 AC 1,145 ms
297,364 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 = array('I', map(int, input().split()))
Q = int(input())
queries = [(map(int, input().split())) for _ in range(Q)]

MAX = max(max(A), 1)
P = array('I', 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]


def solve(p, l, r):
    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:
            return True
        elif diff < ct:
            return False
    return temp == 1


for p, l, r in queries:
    print('Yes' if solve(p, l, r) else 'NO')
0