結果

問題 No.854 公平なりんご分配
ユーザー convexineqconvexineq
提出日時 2021-03-26 06:36:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 880 ms / 3,153 ms
コード長 1,501 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 211,840 KB
最終ジャッジ日時 2024-05-05 17:05:42
合計ジャッジ時間 22,787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
63,616 KB
testcase_01 AC 55 ms
63,488 KB
testcase_02 AC 57 ms
63,872 KB
testcase_03 AC 58 ms
65,024 KB
testcase_04 AC 56 ms
63,616 KB
testcase_05 AC 55 ms
64,128 KB
testcase_06 AC 55 ms
63,744 KB
testcase_07 AC 56 ms
63,872 KB
testcase_08 AC 56 ms
64,256 KB
testcase_09 AC 53 ms
63,616 KB
testcase_10 AC 55 ms
64,768 KB
testcase_11 AC 54 ms
64,256 KB
testcase_12 AC 57 ms
65,152 KB
testcase_13 AC 57 ms
65,024 KB
testcase_14 AC 55 ms
63,488 KB
testcase_15 AC 59 ms
64,384 KB
testcase_16 AC 59 ms
65,024 KB
testcase_17 AC 60 ms
65,280 KB
testcase_18 AC 57 ms
64,768 KB
testcase_19 AC 58 ms
64,640 KB
testcase_20 AC 57 ms
64,640 KB
testcase_21 AC 60 ms
64,768 KB
testcase_22 AC 99 ms
77,696 KB
testcase_23 AC 72 ms
71,040 KB
testcase_24 AC 93 ms
78,464 KB
testcase_25 AC 65 ms
67,968 KB
testcase_26 AC 93 ms
78,208 KB
testcase_27 AC 85 ms
74,368 KB
testcase_28 AC 83 ms
74,624 KB
testcase_29 AC 63 ms
66,304 KB
testcase_30 AC 69 ms
68,352 KB
testcase_31 AC 99 ms
78,208 KB
testcase_32 AC 168 ms
104,144 KB
testcase_33 AC 189 ms
91,392 KB
testcase_34 AC 245 ms
114,616 KB
testcase_35 AC 208 ms
106,824 KB
testcase_36 AC 178 ms
79,284 KB
testcase_37 AC 157 ms
102,148 KB
testcase_38 AC 144 ms
96,768 KB
testcase_39 AC 338 ms
117,212 KB
testcase_40 AC 212 ms
89,216 KB
testcase_41 AC 204 ms
100,096 KB
testcase_42 AC 239 ms
114,392 KB
testcase_43 AC 269 ms
100,912 KB
testcase_44 AC 278 ms
111,852 KB
testcase_45 AC 282 ms
84,224 KB
testcase_46 AC 326 ms
111,060 KB
testcase_47 AC 204 ms
94,720 KB
testcase_48 AC 227 ms
113,952 KB
testcase_49 AC 206 ms
114,588 KB
testcase_50 AC 151 ms
101,768 KB
testcase_51 AC 310 ms
112,744 KB
testcase_52 AC 230 ms
92,144 KB
testcase_53 AC 162 ms
91,264 KB
testcase_54 AC 217 ms
94,720 KB
testcase_55 AC 158 ms
91,776 KB
testcase_56 AC 141 ms
92,544 KB
testcase_57 AC 176 ms
89,600 KB
testcase_58 AC 248 ms
82,816 KB
testcase_59 AC 153 ms
88,064 KB
testcase_60 AC 208 ms
90,392 KB
testcase_61 AC 151 ms
79,524 KB
testcase_62 AC 207 ms
87,808 KB
testcase_63 AC 171 ms
88,320 KB
testcase_64 AC 160 ms
82,440 KB
testcase_65 AC 182 ms
109,276 KB
testcase_66 AC 164 ms
85,632 KB
testcase_67 AC 186 ms
96,768 KB
testcase_68 AC 206 ms
86,272 KB
testcase_69 AC 164 ms
117,160 KB
testcase_70 AC 144 ms
89,216 KB
testcase_71 AC 146 ms
90,496 KB
testcase_72 AC 212 ms
79,708 KB
testcase_73 AC 173 ms
102,504 KB
testcase_74 AC 231 ms
109,060 KB
testcase_75 AC 196 ms
90,772 KB
testcase_76 AC 183 ms
101,312 KB
testcase_77 AC 198 ms
113,556 KB
testcase_78 AC 260 ms
86,996 KB
testcase_79 AC 216 ms
97,920 KB
testcase_80 AC 219 ms
99,440 KB
testcase_81 AC 186 ms
100,416 KB
testcase_82 AC 343 ms
211,200 KB
testcase_83 AC 872 ms
211,328 KB
testcase_84 AC 818 ms
211,712 KB
testcase_85 AC 880 ms
211,328 KB
testcase_86 AC 304 ms
211,072 KB
testcase_87 AC 332 ms
211,712 KB
testcase_88 AC 334 ms
211,200 KB
testcase_89 AC 335 ms
211,840 KB
testcase_90 AC 327 ms
211,456 KB
testcase_91 AC 336 ms
211,328 KB
testcase_92 AC 835 ms
211,456 KB
testcase_93 AC 873 ms
211,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

import sys
input = sys.stdin.readline

n = int(input())
*a, = map(int,input().split())
primes = Eratosthenes(2000)
M = len(primes)
v = [[] for _ in range(2001)]
for i in range(M):
    p = primes[i]
    for j in range(p,2001,p):
        c = 0
        jj = j
        while jj%p==0:
            jj //= p
            c += 1
        #print(p,j)
        v[j].append((i*64+c))

zero = [0]*(n+1)
for i in range(n):
    if a[i]==0: zero[i] = 1
for i in range(n)[::-1]:
    zero[i] += zero[i+1]

MOD = 1<<32
acc = [[0]*(n+1) for _ in range((M+1)//2)]
for i in range(n):
    for pc in v[a[i]]:
        acc[pc//64//2][i] += pc%64*(MOD if pc//64%2 else 1)

for i in range((M+1)//2):
    for j in range(n)[::-1]:
        acc[i][j] += acc[i][j+1]

Q = int(input())
for _ in range(Q):
    x,L,R = map(int,input().split())
    if zero[L-1] - zero[R]:
        print("Yes")
        continue
    for i in range(M):
        pi = primes[i]
        c = 0
        while x%pi==0:
            x //= pi
            c += 1
        if c==0: continue
        d = acc[i//2][L-1] - acc[i//2][R]
        if c > (d//MOD if i%2 else d%MOD):
            print("NO")
            break
    else:
        print("Yes" if x==1 else "NO")
0