結果

問題 No.854 公平なりんご分配
ユーザー ああいい
提出日時 2022-03-04 18:53:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-07-18 15:55:00
合計ジャッジ時間 10,292 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other WA * 50 TLE * 1 -- * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
prime = []
dat = [0] * (2 * 10 ** 3)
for i in range(2,2 * 10 ** 3):
    if dat[i] == 0:
        prime.append(i)
        for j in range(2 * i,2 * 10 ** 3):
            dat[j] = 1
n = len(prime)
_sum = [[0] * n for _ in range(N+1)]
for i in range(N):
    for j in range(n):
        p = prime[j]
        count = 0
        while A[i] % p == 0:
            count += 1
            A[i] //= p
        _sum[i+1][j] = _sum[i][j] + count
Q = int(input())
for _ in range(Q):
    P,l,r = map(int,input().split())
    flag = True
    for j in range(n):
        p = prime[j]
        count = 0
        while P % p == 0:
            count += 1
            P //= p
        if count > _sum[r][j] - _sum[l-1][j]:
            flag = False
            break
    if flag and P == 1:
        print('Yes')
    else:
        print('No')
0