結果

問題 No.854 公平なりんご分配
ユーザー aaaaaaaaaa2230
提出日時 2022-05-20 12:42:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 81,892 KB
実行使用メモリ 82,560 KB
最終ジャッジ日時 2024-09-19 20:26:48
合計ジャッジ時間 17,569 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50 TLE * 1 -- * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int,input().split()))
q = int(input())
P = []
LR = []
for i in range(q):
    p,l,r = map(int,input().split())
    P.append(p)
    LR.append([l-1,r])


M = 2*10**3+5
count = [0]*M
primes = []
for i in range(2,M):
    if count[i]:
        continue
    primes.append(i)
    for j in range(i,M,i):
        count[j] += 1

accum = [0]*(n+1)
for p in primes:
    for i,a in enumerate(A,1):
        c = 0
        na = a
        while na%p == 0:
            na //= p
            c += 1
        accum[i] = accum[i-1]+c

    for i in range(q):
        l,r = LR[i]
        num = accum[r]-accum[l]
        while num and P[i]%p == 0:
            P[i] //= p
            num -= 1
for p in P:
    print("Yes" if p == 1 else "NO")
0