結果

問題 No.854 公平なりんご分配
ユーザー mkawa2mkawa2
提出日時 2021-02-26 01:44:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 2,568 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 387,804 KB
最終ジャッジ日時 2024-04-09 18:02:40
合計ジャッジ時間 83,059 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 32 ms
11,008 KB
testcase_02 AC 32 ms
11,008 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 32 ms
11,008 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 32 ms
10,880 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 32 ms
11,008 KB
testcase_10 AC 32 ms
11,008 KB
testcase_11 AC 32 ms
11,008 KB
testcase_12 AC 32 ms
11,008 KB
testcase_13 AC 32 ms
11,008 KB
testcase_14 AC 31 ms
11,008 KB
testcase_15 AC 33 ms
11,136 KB
testcase_16 AC 32 ms
11,008 KB
testcase_17 AC 32 ms
11,136 KB
testcase_18 AC 31 ms
11,008 KB
testcase_19 AC 32 ms
11,008 KB
testcase_20 AC 32 ms
11,008 KB
testcase_21 AC 31 ms
11,008 KB
testcase_22 AC 44 ms
11,136 KB
testcase_23 AC 57 ms
11,648 KB
testcase_24 AC 89 ms
12,416 KB
testcase_25 AC 48 ms
11,520 KB
testcase_26 AC 88 ms
12,544 KB
testcase_27 AC 77 ms
12,544 KB
testcase_28 AC 42 ms
11,136 KB
testcase_29 AC 37 ms
11,136 KB
testcase_30 AC 47 ms
11,520 KB
testcase_31 AC 78 ms
12,288 KB
testcase_32 AC 1,602 ms
70,400 KB
testcase_33 AC 1,085 ms
41,216 KB
testcase_34 AC 2,591 ms
95,992 KB
testcase_35 AC 1,862 ms
75,904 KB
testcase_36 AC 385 ms
13,568 KB
testcase_37 AC 1,493 ms
66,432 KB
testcase_38 AC 1,190 ms
55,040 KB
testcase_39 AC 3,088 ms
101,932 KB
testcase_40 AC 1,098 ms
36,480 KB
testcase_41 AC 1,601 ms
61,696 KB
testcase_42 AC 2,262 ms
93,924 KB
testcase_43 AC 1,973 ms
64,360 KB
testcase_44 AC 2,449 ms
87,108 KB
testcase_45 AC 1,213 ms
23,424 KB
testcase_46 AC 2,739 ms
85,916 KB
testcase_47 AC 1,301 ms
50,560 KB
testcase_48 AC 2,289 ms
92,740 KB
testcase_49 AC 2,268 ms
94,948 KB
testcase_50 AC 1,438 ms
66,048 KB
testcase_51 AC 2,981 ms
90,368 KB
testcase_52 AC 1,360 ms
42,880 KB
testcase_53 AC 1,021 ms
42,240 KB
testcase_54 AC 1,540 ms
49,408 KB
testcase_55 AC 905 ms
42,240 KB
testcase_56 AC 1,043 ms
44,288 KB
testcase_57 AC 937 ms
37,376 KB
testcase_58 AC 970 ms
20,608 KB
testcase_59 AC 670 ms
33,792 KB
testcase_60 AC 1,019 ms
37,248 KB
testcase_61 AC 286 ms
14,848 KB
testcase_62 AC 1,038 ms
32,768 KB
testcase_63 AC 843 ms
34,560 KB
testcase_64 AC 330 ms
18,560 KB
testcase_65 AC 1,838 ms
83,020 KB
testcase_66 AC 673 ms
26,752 KB
testcase_67 AC 1,387 ms
55,040 KB
testcase_68 AC 927 ms
28,544 KB
testcase_69 AC 2,204 ms
102,076 KB
testcase_70 AC 741 ms
36,736 KB
testcase_71 AC 886 ms
39,424 KB
testcase_72 AC 493 ms
13,696 KB
testcase_73 AC 1,440 ms
67,200 KB
testcase_74 AC 1,988 ms
81,280 KB
testcase_75 AC 995 ms
39,296 KB
testcase_76 AC 1,541 ms
64,256 KB
testcase_77 AC 2,174 ms
92,220 KB
testcase_78 AC 1,195 ms
30,848 KB
testcase_79 AC 1,526 ms
56,448 KB
testcase_80 AC 1,565 ms
59,136 KB
testcase_81 AC 1,447 ms
61,696 KB
testcase_82 TLE -
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

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