結果

問題 No.854 公平なりんご分配
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-21 23:24:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,336 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 81,136 KB
実行使用メモリ 120,180 KB
最終ジャッジ日時 2023-10-21 12:00:50
合計ジャッジ時間 12,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
120,180 KB
testcase_01 AC 39 ms
53,620 KB
testcase_02 AC 39 ms
53,620 KB
testcase_03 AC 39 ms
53,620 KB
testcase_04 AC 39 ms
53,620 KB
testcase_05 AC 39 ms
53,620 KB
testcase_06 AC 38 ms
53,620 KB
testcase_07 AC 39 ms
53,620 KB
testcase_08 AC 39 ms
53,620 KB
testcase_09 AC 39 ms
53,620 KB
testcase_10 AC 40 ms
53,620 KB
testcase_11 AC 40 ms
53,620 KB
testcase_12 AC 47 ms
59,852 KB
testcase_13 AC 43 ms
59,852 KB
testcase_14 AC 39 ms
53,620 KB
testcase_15 AC 39 ms
53,620 KB
testcase_16 AC 43 ms
59,852 KB
testcase_17 AC 43 ms
59,852 KB
testcase_18 AC 43 ms
59,852 KB
testcase_19 AC 43 ms
59,852 KB
testcase_20 AC 43 ms
59,852 KB
testcase_21 AC 44 ms
59,852 KB
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 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 #

from itertools import chain, accumulate
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
U = 2000
U = 100


def prime_set(N):
    """
    Nまでの素数のsetを返す
    """
    if N < 4:
        return ({}, {}, {2}, {2, 3})[N]
    Nsq = int(N ** 0.5 + 0.5) + 1
    primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))
    for i in range(5, Nsq, 2):
        if i in primes:
            primes -= set(range(i * i, N + 1, i * 2))
    return primes


prime = sorted(prime_set(U))
N = int(input())
A = list(map(int, input().split()))

memo = [[0] * (N + 1) for _ in range(len(prime) + 1)]
for i, a in enumerate(A, 1):
    if a == 0:
        memo[0][i] = 1
memo[0] = tuple(accumulate(memo[0]))
for i, p in enumerate(prime, 1):
    for j, a in enumerate(A, 1):
        while a % p == 0:
            memo[i][j] += 1
            a //= p
    memo[i] = tuple(accumulate(memo[i]))

Q = int(input())
ans = []
for _ in range(Q):
    X, S, T = map(int, input().split())
    S -= 1
    ok = (memo[0][T] - memo[0][S] == 0)
    for i, p in enumerate(prime, 1):
        cnt = 0
        while X % p == 0:
            cnt += 1
            X //= p
        ok &= memo[i][T] - memo[i][S] >= cnt
    if ok and X == 1:
        ans.append("Yes")
    else:
        ans.append("NO")

if ans:
    print("\n".join(ans))
0