結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,912 KB
testcase_01 AC 33 ms
54,344 KB
testcase_02 AC 33 ms
54,296 KB
testcase_03 AC 33 ms
53,804 KB
testcase_04 AC 34 ms
53,316 KB
testcase_05 AC 35 ms
53,444 KB
testcase_06 AC 35 ms
54,064 KB
testcase_07 AC 34 ms
53,716 KB
testcase_08 AC 32 ms
53,460 KB
testcase_09 AC 32 ms
53,724 KB
testcase_10 AC 33 ms
53,408 KB
testcase_11 AC 33 ms
54,652 KB
testcase_12 AC 39 ms
62,084 KB
testcase_13 AC 43 ms
61,080 KB
testcase_14 AC 36 ms
53,928 KB
testcase_15 AC 33 ms
54,184 KB
testcase_16 AC 45 ms
61,292 KB
testcase_17 AC 42 ms
61,804 KB
testcase_18 AC 42 ms
60,976 KB
testcase_19 AC 42 ms
61,280 KB
testcase_20 AC 42 ms
60,824 KB
testcase_21 AC 41 ms
60,552 KB
testcase_22 AC 75 ms
74,856 KB
testcase_23 AC 68 ms
73,832 KB
testcase_24 AC 89 ms
78,744 KB
testcase_25 AC 65 ms
71,260 KB
testcase_26 AC 93 ms
78,700 KB
testcase_27 AC 78 ms
76,456 KB
testcase_28 AC 72 ms
75,448 KB
testcase_29 AC 53 ms
67,700 KB
testcase_30 AC 66 ms
71,624 KB
testcase_31 AC 86 ms
78,020 KB
testcase_32 AC 397 ms
155,368 KB
testcase_33 AC 350 ms
94,144 KB
testcase_34 AC 731 ms
185,236 KB
testcase_35 AC 540 ms
162,756 KB
testcase_36 AC 208 ms
81,340 KB
testcase_37 AC 412 ms
151,012 KB
testcase_38 AC 303 ms
98,824 KB
testcase_39 AC 1,070 ms
193,420 KB
testcase_40 AC 371 ms
92,320 KB
testcase_41 AC 493 ms
146,628 KB
testcase_42 AC 644 ms
182,948 KB
testcase_43 AC 691 ms
150,648 KB
testcase_44 AC 797 ms
176,124 KB
testcase_45 AC 440 ms
88,416 KB
testcase_46 AC 962 ms
175,744 KB
testcase_47 AC 364 ms
97,516 KB
testcase_48 AC 619 ms
182,960 KB
testcase_49 AC 590 ms
184,592 KB
testcase_50 AC 363 ms
149,796 KB
testcase_51 AC 985 ms
180,624 KB
testcase_52 AC 424 ms
97,392 KB
testcase_53 AC 311 ms
95,512 KB
testcase_54 AC 442 ms
99,572 KB
testcase_55 AC 265 ms
94,168 KB
testcase_56 AC 278 ms
94,672 KB
testcase_57 AC 316 ms
92,532 KB
testcase_58 AC 390 ms
87,112 KB
testcase_59 AC 239 ms
90,604 KB
testcase_60 AC 349 ms
93,240 KB
testcase_61 AC 178 ms
81,888 KB
testcase_62 AC 386 ms
91,844 KB
testcase_63 AC 279 ms
92,344 KB
testcase_64 AC 187 ms
83,408 KB
testcase_65 AC 485 ms
170,920 KB
testcase_66 AC 262 ms
88,592 KB
testcase_67 AC 393 ms
101,348 KB
testcase_68 AC 310 ms
90,240 KB
testcase_69 AC 470 ms
192,236 KB
testcase_70 AC 234 ms
91,940 KB
testcase_71 AC 252 ms
93,336 KB
testcase_72 AC 244 ms
82,140 KB
testcase_73 AC 387 ms
152,704 KB
testcase_74 AC 558 ms
170,352 KB
testcase_75 AC 313 ms
93,532 KB
testcase_76 AC 430 ms
150,408 KB
testcase_77 AC 539 ms
181,484 KB
testcase_78 AC 440 ms
91,740 KB
testcase_79 AC 476 ms
102,380 KB
testcase_80 AC 501 ms
144,228 KB
testcase_81 AC 412 ms
146,632 KB
testcase_82 AC 1,279 ms
291,428 KB
testcase_83 AC 1,921 ms
291,292 KB
testcase_84 AC 1,876 ms
291,152 KB
testcase_85 AC 1,253 ms
255,460 KB
testcase_86 AC 116 ms
92,076 KB
testcase_87 AC 1,293 ms
291,564 KB
testcase_88 AC 1,310 ms
291,536 KB
testcase_89 AC 1,328 ms
291,300 KB
testcase_90 AC 1,282 ms
291,312 KB
testcase_91 AC 1,301 ms
291,308 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 = [tuple(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