結果
| 問題 |
No.854 公平なりんご分配
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-10-23 21:47:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,185 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,468 KB |
| 実行使用メモリ | 225,872 KB |
| 最終ジャッジ日時 | 2024-09-22 15:12:58 |
| 合計ジャッジ時間 | 16,127 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 TLE * 1 -- * 41 |
ソースコード
import sys
input = sys.stdin.readline
from math import *
def Sieve(n):
lst = [True] * (n + 1)
S = set()
for i in range(2, ceil(sqrt(n)) + 1):
if lst[i]:
for j in range(2 * i, n + 1, i):
lst[j] = False
for i in range(2, n + 1):
if lst[i]:
S.add(i)
return sorted(list(S))
N = int(input())
A = list(map(int, input().split()))
Prime = Sieve(2000)
M = len(Prime)
D = [[0] * N for _ in range(M)]
Dc = [[0] * (N + 1) for _ in range(M)]
for i in range(M):
for j in range(N):
while A[j] % Prime[i] == 0:
A[j] //= Prime[i]
D[i][j] += 1
for j in range(N):
Dc[i][j + 1] = Dc[i][j] + D[i][j]
Q = int(input())
for _ in range(Q):
P, L, R = map(int, input().split())
L -= 1
for i in range(M):
cnt = 0
if P == 1:
print("Yes")
break
v = Prime[i]
while P % v == 0:
cnt += 1
P //= v
if cnt == 0:
continue
if cnt > Dc[i][R] - Dc[i][L]:
print("NO")
break
else:
print("Yes") if P == 1 else print("NO")
rlangevin