結果

問題 No.854 公平なりんご分配
ユーザー ああいいああいい
提出日時 2022-03-04 19:02:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 96,556 KB
最終ジャッジ日時 2023-09-25 20:17:05
合計ジャッジ時間 17,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,180 KB
testcase_01 AC 77 ms
75,172 KB
testcase_02 AC 81 ms
75,336 KB
testcase_03 AC 76 ms
75,356 KB
testcase_04 AC 78 ms
75,296 KB
testcase_05 AC 76 ms
75,376 KB
testcase_06 AC 76 ms
75,340 KB
testcase_07 WA -
testcase_08 AC 75 ms
75,436 KB
testcase_09 AC 75 ms
75,484 KB
testcase_10 AC 78 ms
75,180 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 77 ms
75,180 KB
testcase_15 AC 77 ms
75,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 76 ms
75,356 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 AC 196 ms
96,052 KB
testcase_83 WA -
testcase_84 WA -
testcase_85 AC 299 ms
95,940 KB
testcase_86 AC 188 ms
96,556 KB
testcase_87 AC 219 ms
95,912 KB
testcase_88 AC 217 ms
96,236 KB
testcase_89 AC 212 ms
96,000 KB
testcase_90 AC 215 ms
96,048 KB
testcase_91 AC 217 ms
95,636 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
rr = sys.stdin

N = int(rr.readline())
A = list(map(int,rr.readline().split()))
prime = []
dat = [0] * (2 * 10 ** 3)
for i in range(2,2 * 10 ** 3):
    if dat[i] == 0:
        prime.append(i)
        for j in range(2 * i,2 * 10 ** 3):
            dat[j] = 1
n = len(prime)
_sum = [[0] * n for _ in range(N+1)]

bit = [0] * (N + 1)
def add(i,x):
    while i <= N:
        bit[i] += x
        i += i & -i
def fold(i):
    ans = 0
    while i > 0:
        ans += bit[i]
        i -= i & -i
    return ans

for i in range(N):
    if A[i] == 0:
        add(i+1,1)
        for j in range(n):
            _sum[i+1][j] = _sum[i][j]
        continue
    for j in range(n):
        p = prime[j]
        count = 0
        while A[i] % p == 0:
            count += 1
            A[i] //= p
        _sum[i+1][j] = _sum[i][j] + count
Q = int(rr.readline())
for _ in range(Q):
    P,l,r = map(int,rr.readline().split())
    if fold(r) - fold(l-1) > 0:
        print('Yes')
        continue
    flag = True
    for j in range(n):
        p = prime[j]
        count = 0
        while P % p == 0:
            count += 1
            P //= p
        if count > _sum[r][j] - _sum[l-1][j]:
            flag = False
            break
    if flag and P == 1:
        print('Yes')
    else:
        print('NO')
0