結果

問題 No.854 公平なりんご分配
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-04-10 16:52:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 2,238 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 438,316 KB
最終ジャッジ日時 2023-08-20 22:29:11
合計ジャッジ時間 30,059 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,872 KB
testcase_01 AC 20 ms
8,828 KB
testcase_02 AC 21 ms
8,820 KB
testcase_03 AC 20 ms
8,712 KB
testcase_04 AC 20 ms
8,804 KB
testcase_05 AC 20 ms
8,764 KB
testcase_06 AC 21 ms
8,728 KB
testcase_07 AC 20 ms
8,656 KB
testcase_08 AC 20 ms
8,808 KB
testcase_09 AC 21 ms
8,684 KB
testcase_10 AC 21 ms
8,680 KB
testcase_11 AC 20 ms
8,676 KB
testcase_12 AC 23 ms
8,996 KB
testcase_13 AC 23 ms
8,876 KB
testcase_14 AC 20 ms
8,744 KB
testcase_15 AC 21 ms
8,736 KB
testcase_16 AC 23 ms
8,808 KB
testcase_17 AC 23 ms
8,908 KB
testcase_18 AC 22 ms
9,020 KB
testcase_19 AC 23 ms
8,832 KB
testcase_20 AC 23 ms
8,944 KB
testcase_21 AC 23 ms
8,860 KB
testcase_22 AC 36 ms
9,100 KB
testcase_23 AC 47 ms
10,040 KB
testcase_24 AC 69 ms
11,020 KB
testcase_25 AC 42 ms
9,676 KB
testcase_26 AC 71 ms
11,184 KB
testcase_27 AC 67 ms
11,032 KB
testcase_28 AC 37 ms
9,088 KB
testcase_29 AC 31 ms
9,016 KB
testcase_30 AC 41 ms
9,776 KB
testcase_31 AC 65 ms
10,804 KB
testcase_32 AC 1,004 ms
67,972 KB
testcase_33 AC 645 ms
38,816 KB
testcase_34 AC 1,655 ms
93,232 KB
testcase_35 AC 1,164 ms
73,580 KB
testcase_36 AC 244 ms
12,148 KB
testcase_37 AC 951 ms
63,764 KB
testcase_38 AC 763 ms
52,692 KB
testcase_39 AC 1,784 ms
99,356 KB
testcase_40 AC 617 ms
34,428 KB
testcase_41 AC 970 ms
59,376 KB
testcase_42 AC 1,361 ms
91,632 KB
testcase_43 AC 1,150 ms
61,888 KB
testcase_44 AC 1,451 ms
84,472 KB
testcase_45 AC 615 ms
21,836 KB
testcase_46 AC 1,551 ms
83,460 KB
testcase_47 AC 764 ms
47,752 KB
testcase_48 AC 1,349 ms
89,984 KB
testcase_49 AC 1,382 ms
92,316 KB
testcase_50 AC 942 ms
63,476 KB
testcase_51 AC 1,609 ms
87,828 KB
testcase_52 MLE -
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 #

def answer():
    import sys 
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())

    from collections import defaultdict,Counter
    class prime_factorize():
        
        def __init__(self,M=10**6):
            self.sieve = [-1]*(M+1)
            self.sieve[1] = 1
            self.p = [False]*(M+1)
            for i in range(2,M+1):
                if self.sieve[i] == -1:
                    self.p[i] = True
                    for j in range(i,M+1,i):
                        self.sieve[j] = i
                        
        def factors(self,x):
            tmp = []
            while self.sieve[x] != x:
                tmp.append(self.sieve[x])
                x //= self.sieve[x]
            tmp.append(self.sieve[x])
            return tmp
            
        def is_prime(self,x):
            return self.p[x]
    p = prime_factorize(M=2001)
    p_list = []
    for i in range(1,2001):
        if p.is_prime(i):
            p_list.append(i)
    d = {i:[0]*N for i in p_list}
    for i in range(N):
        a = A[i]
        for k,v in Counter(p.factors(a)).items():
            if k == 1:
                continue 
            d[k][i] += v
            
            
        if i !=0:
            for k in p_list:
                d[k][i] += d[k][i-1]
    
    
    for _ in range(Q):
        P,L,R = map(int,input().split())
        L -= 1
        R -= 1
        dp = defaultdict(lambda:0)
        c_flg = True
        while P != 1 and c_flg:
            flg = True
            for i in p_list:
                if P%i==0:
                    dp[i] += 1
                    P //= i
                    flg = False
                    break
            if flg:
                print('NO')
                c_flg = False
        if not c_flg:
            continue
        
        if L != 0:
            if all(d[k][R]-d[k][L-1] >= dp[k] for k in dp.keys()):
                print('Yes')
            else:
                print('NO')
            continue
        else:
            if all(d[k][R] >= dp[k] for k in dp.keys()):
                print('Yes')
            else:
                print('NO')
            continue
answer()
        
            
            
0