結果

問題 No.854 公平なりんご分配
ユーザー rlangevinrlangevin
提出日時 2023-10-23 21:42:46
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,136 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 81,220 KB
実行使用メモリ 225,152 KB
最終ジャッジ日時 2023-10-23 21:43:07
合計ジャッジ時間 20,468 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
58,872 KB
testcase_01 AC 46 ms
59,648 KB
testcase_02 AC 40 ms
58,888 KB
testcase_03 AC 47 ms
61,956 KB
testcase_04 AC 41 ms
58,936 KB
testcase_05 AC 45 ms
61,680 KB
testcase_06 AC 43 ms
59,708 KB
testcase_07 AC 43 ms
59,708 KB
testcase_08 AC 45 ms
61,680 KB
testcase_09 AC 43 ms
59,708 KB
testcase_10 AC 45 ms
61,956 KB
testcase_11 AC 49 ms
61,680 KB
testcase_12 AC 48 ms
62,000 KB
testcase_13 AC 47 ms
62,000 KB
testcase_14 AC 42 ms
58,936 KB
testcase_15 AC 46 ms
62,000 KB
testcase_16 AC 47 ms
62,000 KB
testcase_17 AC 47 ms
62,000 KB
testcase_18 AC 46 ms
62,000 KB
testcase_19 AC 47 ms
62,000 KB
testcase_20 AC 47 ms
62,000 KB
testcase_21 AC 47 ms
62,000 KB
testcase_22 AC 86 ms
72,652 KB
testcase_23 AC 63 ms
68,292 KB
testcase_24 AC 100 ms
80,524 KB
testcase_25 AC 63 ms
68,308 KB
testcase_26 AC 99 ms
80,756 KB
testcase_27 AC 70 ms
72,404 KB
testcase_28 AC 79 ms
70,592 KB
testcase_29 AC 56 ms
66,216 KB
testcase_30 AC 62 ms
68,284 KB
testcase_31 AC 101 ms
80,224 KB
testcase_32 AC 375 ms
177,356 KB
testcase_33 AC 376 ms
130,376 KB
testcase_34 AC 697 ms
216,376 KB
testcase_35 AC 503 ms
186,204 KB
testcase_36 AC 181 ms
82,512 KB
testcase_37 AC 377 ms
170,856 KB
testcase_38 AC 313 ms
152,484 KB
testcase_39 AC 818 ms
225,152 KB
testcase_40 AC 347 ms
122,188 KB
testcase_41 AC 428 ms
163,440 KB
testcase_42 AC 630 ms
214,128 KB
testcase_43 AC 557 ms
167,576 KB
testcase_44 AC 717 ms
203,472 KB
testcase_45 AC 381 ms
100,592 KB
testcase_46 AC 755 ms
201,716 KB
testcase_47 AC 360 ms
144,992 KB
testcase_48 AC 579 ms
212,016 KB
testcase_49 AC 521 ms
214,796 KB
testcase_50 AC 382 ms
169,976 KB
testcase_51 AC 747 ms
208,208 KB
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from math import *

def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return sorted(list(S))

N = int(input())
A = list(map(int, input().split()))
Prime = Sieve(2000)
M = len(Prime)
D = [[0] * N for _ in range(M)]
Dc = [[0] * (N + 1) for _ in range(M)]
for i in range(M):
    for j in range(N):
        while A[j] % Prime[i] == 0:
            A[j] //= Prime[i]
            D[i][j] += 1
              
    for j in range(N):
        Dc[i][j + 1] = Dc[i][j] + D[i][j]
        
Q = int(input())
for _ in range(Q):
    P, L, R = map(int, input().split())
    L -= 1
    for i in range(M):
        cnt = 0
        if P == 1:
            print("Yes")
            break
        while P % Prime[i] == 0:
            cnt += 1
            P //= Prime[i]
        if cnt > Dc[i][R] - Dc[i][L]:
            print("NO")
            break
    else:
        print("Yes") if P == 1 else print("NO")
0