結果

問題 No.854 公平なりんご分配
ユーザー mkawa2mkawa2
提出日時 2021-02-26 01:45:47
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 2,568 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 320,284 KB
最終ジャッジ日時 2024-04-09 18:03:10
合計ジャッジ時間 25,273 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
56,236 KB
testcase_01 AC 43 ms
55,316 KB
testcase_02 AC 43 ms
55,888 KB
testcase_03 AC 43 ms
54,520 KB
testcase_04 AC 42 ms
54,384 KB
testcase_05 AC 42 ms
55,312 KB
testcase_06 AC 43 ms
56,088 KB
testcase_07 AC 42 ms
55,060 KB
testcase_08 AC 42 ms
55,636 KB
testcase_09 AC 43 ms
54,992 KB
testcase_10 AC 42 ms
55,336 KB
testcase_11 AC 43 ms
56,500 KB
testcase_12 AC 46 ms
60,448 KB
testcase_13 AC 47 ms
60,916 KB
testcase_14 AC 43 ms
55,184 KB
testcase_15 AC 43 ms
55,040 KB
testcase_16 AC 46 ms
61,280 KB
testcase_17 AC 47 ms
61,048 KB
testcase_18 AC 47 ms
60,692 KB
testcase_19 AC 47 ms
60,444 KB
testcase_20 AC 44 ms
55,340 KB
testcase_21 AC 47 ms
61,580 KB
testcase_22 AC 66 ms
67,724 KB
testcase_23 AC 67 ms
70,428 KB
testcase_24 AC 86 ms
78,312 KB
testcase_25 AC 59 ms
66,424 KB
testcase_26 AC 90 ms
77,936 KB
testcase_27 AC 75 ms
73,736 KB
testcase_28 AC 64 ms
67,644 KB
testcase_29 AC 53 ms
63,536 KB
testcase_30 AC 60 ms
67,620 KB
testcase_31 AC 87 ms
77,900 KB
testcase_32 AC 222 ms
127,928 KB
testcase_33 AC 241 ms
105,056 KB
testcase_34 AC 332 ms
148,372 KB
testcase_35 AC 270 ms
132,940 KB
testcase_36 AC 194 ms
80,260 KB
testcase_37 AC 210 ms
124,868 KB
testcase_38 AC 193 ms
116,000 KB
testcase_39 AC 434 ms
152,288 KB
testcase_40 AC 264 ms
101,404 KB
testcase_41 AC 262 ms
121,792 KB
testcase_42 AC 303 ms
146,784 KB
testcase_43 AC 344 ms
124,192 KB
testcase_44 AC 368 ms
141,700 KB
testcase_45 AC 338 ms
89,156 KB
testcase_46 AC 435 ms
140,792 KB
testcase_47 AC 241 ms
112,360 KB
testcase_48 AC 289 ms
145,700 KB
testcase_49 AC 280 ms
147,068 KB
testcase_50 AC 196 ms
124,396 KB
testcase_51 AC 416 ms
144,200 KB
testcase_52 AC 286 ms
106,596 KB
testcase_53 AC 214 ms
106,092 KB
testcase_54 AC 283 ms
111,392 KB
testcase_55 AC 176 ms
106,180 KB
testcase_56 AC 175 ms
107,564 KB
testcase_57 AC 209 ms
101,308 KB
testcase_58 AC 292 ms
86,692 KB
testcase_59 AC 164 ms
98,616 KB
testcase_60 AC 246 ms
101,972 KB
testcase_61 AC 158 ms
81,496 KB
testcase_62 AC 274 ms
97,912 KB
testcase_63 AC 201 ms
98,544 KB
testcase_64 AC 153 ms
85,216 KB
testcase_65 AC 232 ms
137,296 KB
testcase_66 AC 205 ms
92,736 KB
testcase_67 AC 253 ms
116,720 KB
testcase_68 AC 235 ms
94,116 KB
testcase_69 AC 223 ms
151,364 KB
testcase_70 AC 169 ms
101,264 KB
testcase_71 AC 180 ms
103,568 KB
testcase_72 AC 217 ms
80,728 KB
testcase_73 AC 201 ms
125,980 KB
testcase_74 AC 281 ms
137,404 KB
testcase_75 AC 219 ms
103,648 KB
testcase_76 AC 225 ms
123,320 KB
testcase_77 AC 254 ms
145,364 KB
testcase_78 AC 303 ms
96,320 KB
testcase_79 AC 273 ms
117,824 KB
testcase_80 AC 254 ms
119,948 KB
testcase_81 AC 222 ms
121,968 KB
testcase_82 MLE -
testcase_83 MLE -
testcase_84 MLE -
testcase_85 AC 265 ms
90,368 KB
testcase_86 AC 107 ms
89,824 KB
testcase_87 MLE -
testcase_88 MLE -
testcase_89 MLE -
testcase_90 MLE -
testcase_91 MLE -
testcase_92 MLE -
testcase_93 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def FI(): return float(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MF(): return map(float, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**16
# md = 998244353
md = 10**9+7

class Sieve:
    def __init__(self, n):
        self.plist = [2]  # n以下の素数のリスト
        min_prime_factor = [2, 0]*(n//2+5)
        for x in range(3, n+1, 2):
            if min_prime_factor[x] == 0:
                min_prime_factor[x] = x
                self.plist.append(x)
                if x**2 > n: continue
                for y in range(x**2, n+5, 2*x):
                    if min_prime_factor[y] == 0:
                        min_prime_factor[y] = x
        self.min_prime_factor = min_prime_factor

    def isprime(self, x):
        return self.min_prime_factor[x] == x

    # これが素因数分解(prime factorization)
    def pfct(self, x):
        pp, ee = [], []
        while x > 1:
            mpf = self.min_prime_factor[x]
            if pp and mpf == pp[-1]:
                ee[-1] += 1
            else:
                pp.append(mpf)
                ee.append(1)
            x //= mpf
        return [(p, e) for p, e in zip(pp, ee)]

from collections import defaultdict

sv = Sieve(2005)
n = II()
aa = LI()
df = lambda: [0]*(n+1)
cs = defaultdict(df)

for i, a in enumerate(aa):
    if a == 0:
        cs[0][i+1] = 1
    else:
        pe = sv.pfct(a)
        for p, e in pe: cs[p][i+1] = e

for k, v in cs.items():
    for i in range(n): v[i+1] += v[i]
# print(cs)

def ok(a):
    if a == 1: return True
    if cs[0][r]-cs[0][l]: return True
    for p in cs.keys():
        if p == 0: continue
        e = 0
        while a%p == 0:
            a //= p
            e += 1
        if e and cs[p][r]-cs[p][l] < e: return False
    if a != 1: return False
    return True

for _ in range(II()):
    a, l, r = MI()
    l -= 1
    print("Yes" if ok(a) else "NO")
0