結果

問題 No.854 公平なりんご分配
ユーザー convexineqconvexineq
提出日時 2021-03-26 06:36:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,000 ms / 3,153 ms
コード長 1,501 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 204,256 KB
最終ジャッジ日時 2023-08-18 11:46:10
合計ジャッジ時間 27,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
76,812 KB
testcase_01 AC 87 ms
76,712 KB
testcase_02 AC 88 ms
76,888 KB
testcase_03 AC 88 ms
77,316 KB
testcase_04 AC 89 ms
76,636 KB
testcase_05 AC 89 ms
76,844 KB
testcase_06 AC 87 ms
76,752 KB
testcase_07 AC 86 ms
76,516 KB
testcase_08 AC 88 ms
76,852 KB
testcase_09 AC 88 ms
76,572 KB
testcase_10 AC 93 ms
77,216 KB
testcase_11 AC 92 ms
76,868 KB
testcase_12 AC 94 ms
76,788 KB
testcase_13 AC 93 ms
76,968 KB
testcase_14 AC 89 ms
76,764 KB
testcase_15 AC 90 ms
76,596 KB
testcase_16 AC 94 ms
76,720 KB
testcase_17 AC 94 ms
76,880 KB
testcase_18 AC 90 ms
77,016 KB
testcase_19 AC 91 ms
76,924 KB
testcase_20 AC 90 ms
77,004 KB
testcase_21 AC 91 ms
76,696 KB
testcase_22 AC 127 ms
79,108 KB
testcase_23 AC 108 ms
78,000 KB
testcase_24 AC 129 ms
79,964 KB
testcase_25 AC 98 ms
77,004 KB
testcase_26 AC 126 ms
79,424 KB
testcase_27 AC 117 ms
79,920 KB
testcase_28 AC 120 ms
78,788 KB
testcase_29 AC 95 ms
76,992 KB
testcase_30 AC 99 ms
76,852 KB
testcase_31 AC 124 ms
79,628 KB
testcase_32 AC 201 ms
105,036 KB
testcase_33 AC 240 ms
92,692 KB
testcase_34 AC 297 ms
116,572 KB
testcase_35 AC 258 ms
107,880 KB
testcase_36 AC 222 ms
80,616 KB
testcase_37 AC 190 ms
103,488 KB
testcase_38 AC 179 ms
98,420 KB
testcase_39 AC 392 ms
119,040 KB
testcase_40 AC 253 ms
90,792 KB
testcase_41 AC 253 ms
101,856 KB
testcase_42 AC 276 ms
115,780 KB
testcase_43 AC 322 ms
102,780 KB
testcase_44 AC 324 ms
112,768 KB
testcase_45 AC 348 ms
85,108 KB
testcase_46 AC 387 ms
112,120 KB
testcase_47 AC 244 ms
97,272 KB
testcase_48 AC 267 ms
115,376 KB
testcase_49 AC 240 ms
115,888 KB
testcase_50 AC 186 ms
103,124 KB
testcase_51 AC 385 ms
114,024 KB
testcase_52 AC 280 ms
93,272 KB
testcase_53 AC 205 ms
92,768 KB
testcase_54 AC 265 ms
96,404 KB
testcase_55 AC 177 ms
93,292 KB
testcase_56 AC 178 ms
94,212 KB
testcase_57 AC 224 ms
91,272 KB
testcase_58 AC 316 ms
83,984 KB
testcase_59 AC 192 ms
89,272 KB
testcase_60 AC 261 ms
91,460 KB
testcase_61 AC 189 ms
81,412 KB
testcase_62 AC 258 ms
89,016 KB
testcase_63 AC 206 ms
89,388 KB
testcase_64 AC 200 ms
83,304 KB
testcase_65 AC 217 ms
110,972 KB
testcase_66 AC 212 ms
86,152 KB
testcase_67 AC 238 ms
98,960 KB
testcase_68 AC 262 ms
87,276 KB
testcase_69 AC 198 ms
118,620 KB
testcase_70 AC 181 ms
90,624 KB
testcase_71 AC 182 ms
91,544 KB
testcase_72 AC 271 ms
81,376 KB
testcase_73 AC 198 ms
104,220 KB
testcase_74 AC 262 ms
110,164 KB
testcase_75 AC 241 ms
92,280 KB
testcase_76 AC 222 ms
102,556 KB
testcase_77 AC 246 ms
114,740 KB
testcase_78 AC 329 ms
88,860 KB
testcase_79 AC 265 ms
99,300 KB
testcase_80 AC 265 ms
100,768 KB
testcase_81 AC 222 ms
101,648 KB
testcase_82 AC 363 ms
203,692 KB
testcase_83 AC 973 ms
202,412 KB
testcase_84 AC 932 ms
204,256 KB
testcase_85 AC 1,000 ms
202,028 KB
testcase_86 AC 333 ms
203,612 KB
testcase_87 AC 364 ms
199,232 KB
testcase_88 AC 360 ms
199,000 KB
testcase_89 AC 368 ms
199,076 KB
testcase_90 AC 362 ms
198,920 KB
testcase_91 AC 364 ms
199,192 KB
testcase_92 AC 975 ms
199,884 KB
testcase_93 AC 983 ms
199,764 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