結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
58,564 KB
testcase_01 AC 40 ms
53,000 KB
testcase_02 AC 38 ms
52,852 KB
testcase_03 AC 40 ms
53,032 KB
testcase_04 AC 38 ms
54,032 KB
testcase_05 AC 39 ms
54,524 KB
testcase_06 AC 38 ms
52,992 KB
testcase_07 AC 38 ms
53,700 KB
testcase_08 AC 38 ms
53,096 KB
testcase_09 AC 38 ms
54,212 KB
testcase_10 AC 38 ms
54,228 KB
testcase_11 AC 39 ms
52,896 KB
testcase_12 AC 45 ms
60,680 KB
testcase_13 AC 45 ms
61,080 KB
testcase_14 AC 38 ms
53,576 KB
testcase_15 AC 39 ms
54,764 KB
testcase_16 AC 46 ms
61,284 KB
testcase_17 AC 46 ms
60,704 KB
testcase_18 AC 44 ms
60,296 KB
testcase_19 AC 45 ms
61,340 KB
testcase_20 AC 45 ms
60,728 KB
testcase_21 AC 45 ms
60,628 KB
testcase_22 AC 73 ms
72,236 KB
testcase_23 AC 71 ms
71,068 KB
testcase_24 AC 88 ms
75,864 KB
testcase_25 AC 68 ms
70,212 KB
testcase_26 AC 92 ms
76,728 KB
testcase_27 AC 79 ms
73,596 KB
testcase_28 AC 73 ms
72,476 KB
testcase_29 AC 59 ms
67,228 KB
testcase_30 AC 68 ms
71,696 KB
testcase_31 AC 89 ms
76,404 KB
testcase_32 AC 441 ms
155,080 KB
testcase_33 AC 440 ms
95,728 KB
testcase_34 AC 857 ms
187,404 KB
testcase_35 AC 646 ms
163,552 KB
testcase_36 AC 238 ms
84,080 KB
testcase_37 AC 444 ms
151,344 KB
testcase_38 AC 325 ms
98,920 KB
testcase_39 AC 1,276 ms
198,340 KB
testcase_40 AC 498 ms
95,360 KB
testcase_41 AC 626 ms
147,960 KB
testcase_42 AC 762 ms
185,000 KB
testcase_43 AC 885 ms
154,112 KB
testcase_44 AC 942 ms
179,296 KB
testcase_45 AC 550 ms
93,892 KB
testcase_46 AC 1,214 ms
181,144 KB
testcase_47 AC 469 ms
98,716 KB
testcase_48 AC 700 ms
182,556 KB
testcase_49 AC 667 ms
184,712 KB
testcase_50 AC 404 ms
149,708 KB
testcase_51 AC 1,192 ms
185,736 KB
testcase_52 AC 576 ms
102,524 KB
testcase_53 AC 370 ms
97,276 KB
testcase_54 AC 592 ms
104,560 KB
testcase_55 AC 298 ms
95,432 KB
testcase_56 AC 297 ms
95,120 KB
testcase_57 AC 384 ms
94,496 KB
testcase_58 AC 431 ms
92,908 KB
testcase_59 AC 255 ms
90,848 KB
testcase_60 AC 437 ms
96,580 KB
testcase_61 AC 210 ms
84,072 KB
testcase_62 AC 472 ms
95,864 KB
testcase_63 AC 337 ms
95,876 KB
testcase_64 AC 212 ms
84,168 KB
testcase_65 AC 531 ms
170,968 KB
testcase_66 AC 315 ms
90,444 KB
testcase_67 AC 494 ms
104,748 KB
testcase_68 AC 382 ms
95,380 KB
testcase_69 AC 487 ms
190,856 KB
testcase_70 AC 271 ms
92,596 KB
testcase_71 AC 293 ms
94,340 KB
testcase_72 AC 285 ms
86,092 KB
testcase_73 AC 411 ms
153,228 KB
testcase_74 AC 658 ms
174,096 KB
testcase_75 AC 381 ms
95,448 KB
testcase_76 AC 477 ms
153,780 KB
testcase_77 AC 578 ms
184,876 KB
testcase_78 AC 521 ms
97,212 KB
testcase_79 AC 599 ms
107,180 KB
testcase_80 AC 633 ms
148,400 KB
testcase_81 AC 468 ms
149,140 KB
testcase_82 AC 1,273 ms
297,288 KB
testcase_83 AC 1,949 ms
297,224 KB
testcase_84 AC 1,907 ms
297,136 KB
testcase_85 AC 1,269 ms
257,628 KB
testcase_86 AC 137 ms
104,016 KB
testcase_87 AC 1,300 ms
297,260 KB
testcase_88 AC 1,283 ms
297,104 KB
testcase_89 AC 1,276 ms
297,232 KB
testcase_90 AC 1,288 ms
297,004 KB
testcase_91 AC 1,287 ms
296,916 KB
testcase_92 TLE -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

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